|
| 1 | +use ahash::{HashSet, HashSetExt}; |
1 | 2 | use anyhow::{anyhow, bail, Context, Error, Result};
|
2 | 3 | use std::{
|
3 | 4 | cmp::Ordering,
|
@@ -48,9 +49,9 @@ fn check_cargo_toml(
|
48 | 49 | }
|
49 | 50 |
|
50 | 51 | // Check the info of all exercises and return their paths in a set.
|
51 |
| -fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<PathBuf>> { |
52 |
| - let mut names = hashbrown::HashSet::with_capacity(info_file.exercises.len()); |
53 |
| - let mut paths = hashbrown::HashSet::with_capacity(info_file.exercises.len()); |
| 52 | +fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> { |
| 53 | + let mut names = HashSet::with_capacity(info_file.exercises.len()); |
| 54 | + let mut paths = HashSet::with_capacity(info_file.exercises.len()); |
54 | 55 |
|
55 | 56 | let mut file_buf = String::with_capacity(1 << 14);
|
56 | 57 | for exercise_info in &info_file.exercises {
|
@@ -111,10 +112,7 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<
|
111 | 112 | // Check `dir` for unexpected files.
|
112 | 113 | // Only Rust files in `allowed_rust_files` and `README.md` files are allowed.
|
113 | 114 | // Only one level of directory nesting is allowed.
|
114 |
| -fn check_unexpected_files( |
115 |
| - dir: &str, |
116 |
| - allowed_rust_files: &hashbrown::HashSet<PathBuf>, |
117 |
| -) -> Result<()> { |
| 115 | +fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet<PathBuf>) -> Result<()> { |
118 | 116 | let unexpected_file = |path: &Path| {
|
119 | 117 | anyhow!("Found the file `{}`. Only `README.md` and Rust files related to an exercise in `info.toml` are allowed in the `{dir}` directory", path.display())
|
120 | 118 | };
|
@@ -253,7 +251,7 @@ fn check_solutions(
|
253 | 251 | })
|
254 | 252 | .collect::<Vec<_>>();
|
255 | 253 |
|
256 |
| - let mut sol_paths = hashbrown::HashSet::with_capacity(info_file.exercises.len()); |
| 254 | + let mut sol_paths = HashSet::with_capacity(info_file.exercises.len()); |
257 | 255 | let mut fmt_cmd = Command::new("rustfmt");
|
258 | 256 | fmt_cmd
|
259 | 257 | .arg("--check")
|
|
0 commit comments