mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-04 10:35:06 +02:00
commit
b8a5886db4
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -271,6 +271,15 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.5"
|
||||
@ -561,7 +570,7 @@ dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"toml",
|
||||
"toml_edit",
|
||||
"which",
|
||||
]
|
||||
|
||||
@ -643,18 +652,6 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.5"
|
||||
@ -666,9 +663,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.6"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6"
|
||||
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
@ -17,7 +17,7 @@ notify-debouncer-mini = "0.4.1"
|
||||
regex = "1.10.3"
|
||||
serde_json = "1.0.114"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
toml = "0.8.10"
|
||||
toml_edit = { version = "0.22.9", default-features = false, features = ["parse", "serde"] }
|
||||
which = "6.0.1"
|
||||
|
||||
[[bin]]
|
||||
|
23
src/main.rs
23
src/main.rs
@ -91,15 +91,6 @@ fn main() {
|
||||
println!("\n{WELCOME}\n");
|
||||
}
|
||||
|
||||
if !Path::new("info.toml").exists() {
|
||||
println!(
|
||||
"{} must be run from the rustlings directory",
|
||||
std::env::current_exe().unwrap().to_str().unwrap()
|
||||
);
|
||||
println!("Try `cd rustlings/`!");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
if which::which("rustc").is_err() {
|
||||
println!("We cannot find `rustc`.");
|
||||
println!("Try running `rustc --version` to diagnose your problem.");
|
||||
@ -107,8 +98,18 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let toml_str = &fs::read_to_string("info.toml").unwrap();
|
||||
let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
|
||||
let info_file = fs::read_to_string("info.toml").unwrap_or_else(|e| {
|
||||
match e.kind() {
|
||||
io::ErrorKind::NotFound => println!(
|
||||
"The program must be run from the rustlings directory\nTry `cd rustlings/`!",
|
||||
),
|
||||
_ => println!("Failed to read the info.toml file: {e}"),
|
||||
}
|
||||
std::process::exit(1);
|
||||
});
|
||||
let exercises = toml_edit::de::from_str::<ExerciseList>(&info_file)
|
||||
.unwrap()
|
||||
.exercises;
|
||||
let verbose = args.nocapture;
|
||||
|
||||
let command = args.command.unwrap_or_else(|| {
|
||||
|
Loading…
Reference in New Issue
Block a user