mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-25 23:10:30 +00:00
Remove redundant checks
This commit is contained in:
parent
28ec0f864a
commit
b9167e9299
2 changed files with 2 additions and 17 deletions
|
@ -15,8 +15,8 @@ pub fn include_files(_: TokenStream) -> TokenStream {
|
||||||
let mut files = Vec::with_capacity(8);
|
let mut files = Vec::with_capacity(8);
|
||||||
let mut dirs = Vec::with_capacity(128);
|
let mut dirs = Vec::with_capacity(128);
|
||||||
|
|
||||||
for entry in read_dir("exercises").expect("Failed to open the exercises directory") {
|
for entry in read_dir("exercises").expect("Failed to open the `exercises` directory") {
|
||||||
let entry = entry.expect("Failed to read the exercises directory");
|
let entry = entry.expect("Failed to read the `exercises` directory");
|
||||||
|
|
||||||
if entry.file_type().unwrap().is_file() {
|
if entry.file_type().unwrap().is_file() {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
@ -46,13 +46,6 @@ pub fn include_files(_: TokenStream) -> TokenStream {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if path.extension() != Some("rs".as_ref()) {
|
|
||||||
panic!(
|
|
||||||
"Found {} but expected only README.md and .rs files",
|
|
||||||
path.display(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(path_to_string(path))
|
Some(path_to_string(path))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,6 @@ impl InfoFile {
|
||||||
bail!("{NO_EXERCISES_ERR}");
|
bail!("{NO_EXERCISES_ERR}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut names_set = hashbrown::HashSet::with_capacity(slf.exercises.len());
|
|
||||||
for exercise in &slf.exercises {
|
|
||||||
if !names_set.insert(exercise.name.as_str()) {
|
|
||||||
bail!("Exercise names must all be unique!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drop(names_set);
|
|
||||||
|
|
||||||
Ok(slf)
|
Ok(slf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue