summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app_state.rs4
-rw-r--r--src/collections.rs9
-rw-r--r--src/dev/check.rs8
-rw-r--r--src/main.rs1
4 files changed, 6 insertions, 16 deletions
diff --git a/src/app_state.rs b/src/app_state.rs
index 4007fbc..5979150 100644
--- a/src/app_state.rs
+++ b/src/app_state.rs
@@ -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},
@@ -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,
@@ -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() {
diff --git a/src/collections.rs b/src/collections.rs
deleted file mode 100644
index 3f2841e..0000000
--- a/src/collections.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use foldhash::fast::FixedState;
-
-/// DOS attacks aren't a concern for Rustlings. Therefore, we use `foldhash` with a fixed state.
-pub type HashSet<T> = std::collections::HashSet<T, FixedState>;
-
-#[inline]
-pub fn hash_set_with_capacity<T>(capacity: usize) -> HashSet<T> {
- HashSet::with_capacity_and_hasher(capacity, FixedState::default())
-}
diff --git a/src/dev/check.rs b/src/dev/check.rs
index 119fed5..956c2be 100644
--- a/src/dev/check.rs
+++ b/src/dev/check.rs
@@ -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},
@@ -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,
@@ -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 {
@@ -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")
diff --git a/src/main.rs b/src/main.rs
index c8bcd2e..eeb1883 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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;