我在从crates.io导入rand crate时遇到问题。添加行 rand="0.8.3" 然后为项目运行命令Cargo build后,它不断显示相同的错误:
error[E0432]: unresolved import `rand`
--> main.rs:1:5
|
1 | use rand::Rng;
| ^^^^ maybe a missing crate `rand`?
error[E0433]: failed to resolve: use of undeclared crate or module `rand`
--> main.rs:4:25
|
4 | let secret_number = rand::thread_rng().gen_range(1..=11);
| ^^^^ use of undeclared crate or module `rand`
error: aborting due to 2 previous errors
Run Code Online (Sandbox Code Playgroud)
Cargo.toml文件
[package]
name = "roller"
version = "0.1.0"
authors = ["User"]
edition = "2018"
# See more keys …Run Code Online (Sandbox Code Playgroud)