Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ include = [
]

[dependencies]
ahash = "0.8.11"
anyhow = "1.0.86"
clap = { version = "4.5.13", features = ["derive"] }
hashbrown = "0.14.5"
notify-debouncer-mini = { version = "0.4.1", default-features = false }
os_pipe = "1.2.1"
ratatui = { version = "0.27.0", default-features = false, features = ["crossterm"] }
Expand Down
3 changes: 2 additions & 1 deletion src/app_state.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ahash::{HashSet, HashSetExt};
use anyhow::{bail, Context, Error, Result};
use std::{
fs::{self, File},
Expand Down Expand Up @@ -69,7 +70,7 @@ impl AppState {
return StateFileStatus::NotRead;
}

let mut done_exercises = hashbrown::HashSet::with_capacity(self.exercises.len());
let mut done_exercises = HashSet::with_capacity(self.exercises.len());

for done_exerise_name in lines {
if done_exerise_name.is_empty() {
Expand Down
14 changes: 6 additions & 8 deletions src/dev/check.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ahash::{HashSet, HashSetExt};
use anyhow::{anyhow, bail, Context, Error, Result};
use std::{
cmp::Ordering,
Expand Down Expand Up @@ -48,9 +49,9 @@ fn check_cargo_toml(
}

// Check the info of all exercises and return their paths in a set.
fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<PathBuf>> {
let mut names = hashbrown::HashSet::with_capacity(info_file.exercises.len());
let mut paths = hashbrown::HashSet::with_capacity(info_file.exercises.len());
fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> {
let mut names = HashSet::with_capacity(info_file.exercises.len());
let mut paths = HashSet::with_capacity(info_file.exercises.len());

let mut file_buf = String::with_capacity(1 << 14);
for exercise_info in &info_file.exercises {
Expand Down Expand Up @@ -111,10 +112,7 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<
// Check `dir` for unexpected files.
// Only Rust files in `allowed_rust_files` and `README.md` files are allowed.
// Only one level of directory nesting is allowed.
fn check_unexpected_files(
dir: &str,
allowed_rust_files: &hashbrown::HashSet<PathBuf>,
) -> Result<()> {
fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet<PathBuf>) -> Result<()> {
let unexpected_file = |path: &Path| {
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())
};
Expand Down Expand Up @@ -253,7 +251,7 @@ fn check_solutions(
})
.collect::<Vec<_>>();

let mut sol_paths = hashbrown::HashSet::with_capacity(info_file.exercises.len());
let mut sol_paths = HashSet::with_capacity(info_file.exercises.len());
let mut fmt_cmd = Command::new("rustfmt");
fmt_cmd
.arg("--check")
Expand Down