Skip to content

Commit

Permalink
Use the default hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
mo8it committed Oct 17, 2024
1 parent e90f5f0 commit 7e2f56f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 31 deletions.
15 changes: 4 additions & 11 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ include = [
anyhow = "1.0.89"
clap = { version = "4.5.20", features = ["derive"] }
crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] }
foldhash = "0.1.3"
notify = { version = "6.1.1", default-features = false, features = ["macos_fsevent"] }
os_pipe = "1.2.1"
rustlings-macros = { path = "rustlings-macros", version = "=6.3.0" }
Expand Down
3 changes: 0 additions & 3 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ disallowed-types = [
]

disallowed-methods = [
# We use `foldhash` instead of the default hasher.
"std::collections::HashSet::new",
"std::collections::HashSet::with_capacity",
# Inefficient. Use `.queue(…)` instead.
"crossterm::style::style",
# Use `thread::Builder::spawn` instead and handle the error.
Expand Down
4 changes: 2 additions & 2 deletions src/app_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{bail, Context, Error, Result};
use crossterm::{cursor, terminal, QueueableCommand};
use std::{
collections::HashSet,
env,
fs::{File, OpenOptions},
io::{Read, Seek, StdoutLock, Write},
Expand All @@ -16,7 +17,6 @@ use std::{
use crate::{
clear_terminal,
cmd::CmdRunner,
collections::hash_set_with_capacity,
embedded::EMBEDDED_FILES,
exercise::{Exercise, RunnableExercise},
info_file::ExerciseInfo,
Expand Down Expand Up @@ -146,7 +146,7 @@ impl AppState {
break 'block StateFileStatus::NotRead;
}

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

for done_exercise_name in lines {
if done_exercise_name.is_empty() {
Expand Down
9 changes: 0 additions & 9 deletions src/collections.rs

This file was deleted.

8 changes: 4 additions & 4 deletions src/dev/check.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{anyhow, bail, Context, Error, Result};
use std::{
cmp::Ordering,
collections::HashSet,
fs::{self, read_dir, OpenOptions},
io::{self, Read, Write},
path::{Path, PathBuf},
Expand All @@ -11,7 +12,6 @@ use std::{
use crate::{
cargo_toml::{append_bins, bins_start_end_ind, BINS_BUFFER_CAPACITY},
cmd::CmdRunner,
collections::{hash_set_with_capacity, HashSet},
exercise::{RunnableExercise, OUTPUT_CAPACITY},
info_file::{ExerciseInfo, InfoFile},
CURRENT_FORMAT_VERSION,
Expand Down Expand Up @@ -53,8 +53,8 @@ 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<HashSet<PathBuf>> {
let mut names = hash_set_with_capacity(info_file.exercises.len());
let mut paths = hash_set_with_capacity(info_file.exercises.len());
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 @@ -282,7 +282,7 @@ fn check_solutions(
.collect::<Result<Vec<_>, _>>()
.context("Failed to spawn a thread to check a solution")?;

let mut sol_paths = hash_set_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
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use self::{app_state::AppState, dev::DevCommands, info_file::InfoFile};
mod app_state;
mod cargo_toml;
mod cmd;
mod collections;
mod dev;
mod embedded;
mod exercise;
Expand Down

0 comments on commit 7e2f56f

Please sign in to comment.