-
Notifications
You must be signed in to change notification settings - Fork 252
Open
Description
When loading code from the crate example page using "Load in playground," an error occurs due to a version difference.
use rand::Rng;
fn main() {
let mut rng = rand::thread_rng();
println!("{}", rng.gen::<u8>());
} Compiling playground v0.0.1 (/playground)
error: expected identifier, found reserved keyword `gen`
--> src/main.rs:5:24
|
5 | println!("{}", rng.gen::<u8>());
| ^^^ expected identifier, found reserved keyword
|
help: escape `gen` to use it as an identifier
|
5 | println!("{}", rng.r#gen::<u8>());
| ++
error[E0425]: cannot find function `thread_rng` in crate `rand`
--> src/main.rs:4:25
|
4 | let mut rng = rand::thread_rng();
| ^^^^^^^^^^ not found in `rand`
|
help: consider importing one of these functions
|
1 + use rand_0_8_5::thread_rng;
|
1 + use rand_0_9_2::thread_rng;
|
help: if you import `thread_rng`, refer to it directly
|
4 - let mut rng = rand::thread_rng();
4 + let mut rng = thread_rng();
|
warning: unused import: `rand::Rng`
--> src/main.rs:1:5
|
1 | use rand::Rng;
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
For more information about this error, try `rustc --explain E0425`.
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` (bin "playground") due to 2 previous errors; 1 warning emitted
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.