mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-11-08 09:09:17 +01:00
Remove unwrap on canonicalize result
This commit is contained in:
parent
d01a71f7de
commit
8c867a001a
13
src/main.rs
13
src/main.rs
@ -67,11 +67,14 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
let filepath = Path::new(filename).canonicalize().unwrap();
|
||||
let exercise = exercises
|
||||
.iter()
|
||||
.find(|e| filepath.ends_with(&e.path))
|
||||
.unwrap_or_else(|| {
|
||||
let matching_exercise = |e: &&Exercise| {
|
||||
Path::new(filename)
|
||||
.canonicalize()
|
||||
.map(|p| p.ends_with(&e.path))
|
||||
.unwrap_or(false)
|
||||
};
|
||||
|
||||
let exercise = exercises.iter().find(matching_exercise).unwrap_or_else(|| {
|
||||
println!("No exercise found for your file name!");
|
||||
std::process::exit(1)
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user