Errors during compilation code from lesson 2

I programming guessing game from book https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html however i have errors.

error[E0432]: unresolved import rand
--> src\main.rs:1:5
|
1 | use rand::Rng;
| ^^^^ use of undeclared type or module rand

error[E0433]: failed to resolve: use of undeclared type or module rand
--> src\main.rs:8:25
|
8 | let secret_number = rand::thread_rng().gen_range(1, 101);
| ^^^^ use of undeclared type or module rand

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try rustc --explain E0432.
error: could not compile proba.

Code is the same how in documentation. Please help. Sorry for my bad language.

You need to add the rand crate to your dependencies as described here.

1 Like

Thank you :grinning: