0

I'm trying to use rand::random function in Rust:

use rand::random;

fn main(){
  println!("{}",rand::random::<f64>());
}

It didn't work, the rand crate was not installed by default. So I installed it:

$ cargo install rand

However, after installing rand crate, the programme is still not running, error:

  |
8 | use rand::random;
  |     ^^^^ maybe a missing crate `rand`?

I wish to use rustc command instead of cargo as I need to specify different programme files instead of main.rs:

rustc -L rand myprog.rs

How to use crates with rustc command?

Dee
  • 7,455
  • 6
  • 36
  • 70

0 Answers0