style: format the whole tree with cargo fmt (stock defaults, #35)
One-time, mechanical reformat — no functional changes. The tree was not rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock `cargo fmt` defaults so a `cargo fmt --check` CI gate can follow. Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline), clippy clean. A .git-blame-ignore-revs entry follows so `git blame` skips this commit.
This commit is contained in:
+30
-15
@@ -17,8 +17,8 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use rand::seq::IndexedRandom;
|
||||
use rand::Rng;
|
||||
use rand::seq::IndexedRandom;
|
||||
|
||||
const WORDLIST: &str = include_str!("wordlist.txt");
|
||||
const MAX_COLLISION_RETRIES: usize = 100;
|
||||
@@ -41,10 +41,9 @@ pub enum NamingError {
|
||||
impl std::fmt::Display for NamingError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::WordlistTooSmall(n) => f.write_str(&crate::t!(
|
||||
"project.naming.wordlist_too_small",
|
||||
count = n,
|
||||
)),
|
||||
Self::WordlistTooSmall(n) => {
|
||||
f.write_str(&crate::t!("project.naming.wordlist_too_small", count = n,))
|
||||
}
|
||||
Self::TooManyCollisions(n) => f.write_str(&crate::t!(
|
||||
"project.naming.too_many_collisions",
|
||||
attempts = n,
|
||||
@@ -189,10 +188,9 @@ impl std::fmt::Display for UserNameError {
|
||||
match self {
|
||||
Self::Empty => f.write_str(&crate::t!("project.user_name.empty")),
|
||||
Self::LeadingDot => f.write_str(&crate::t!("project.user_name.leading_dot")),
|
||||
Self::InvalidChar(c) => f.write_str(&crate::t!(
|
||||
"project.user_name.invalid_char",
|
||||
ch = c,
|
||||
)),
|
||||
Self::InvalidChar(c) => {
|
||||
f.write_str(&crate::t!("project.user_name.invalid_char", ch = c,))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,14 +207,22 @@ mod tests {
|
||||
#[test]
|
||||
fn wordlist_has_enough_entries() {
|
||||
let pool = words();
|
||||
assert!(pool.len() >= 100, "wordlist suspiciously small: {} entries", pool.len());
|
||||
assert!(
|
||||
pool.len() >= 100,
|
||||
"wordlist suspiciously small: {} entries",
|
||||
pool.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wordlist_has_no_duplicates() {
|
||||
let pool = words();
|
||||
let unique: std::collections::HashSet<_> = pool.iter().collect();
|
||||
assert_eq!(unique.len(), pool.len(), "wordlist contains duplicate entries");
|
||||
assert_eq!(
|
||||
unique.len(),
|
||||
pool.len(),
|
||||
"wordlist contains duplicate entries"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -290,7 +296,7 @@ mod tests {
|
||||
assert!(!is_temp_dirname("MyOrders"));
|
||||
assert!(!is_temp_dirname("term_planner"));
|
||||
assert!(!is_temp_dirname("20260507-water-buffalo-skating")); // no marker
|
||||
assert!(!is_temp_dirname("temp-project")); // no brackets
|
||||
assert!(!is_temp_dirname("temp-project")); // no brackets
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -301,9 +307,18 @@ mod tests {
|
||||
assert!(validate_user_name("project.v2").is_ok());
|
||||
|
||||
assert_eq!(validate_user_name(""), Err(UserNameError::Empty));
|
||||
assert_eq!(validate_user_name(".hidden"), Err(UserNameError::LeadingDot));
|
||||
assert!(matches!(validate_user_name("a/b"), Err(UserNameError::InvalidChar('/'))));
|
||||
assert!(matches!(validate_user_name("a b"), Err(UserNameError::InvalidChar(' '))));
|
||||
assert_eq!(
|
||||
validate_user_name(".hidden"),
|
||||
Err(UserNameError::LeadingDot)
|
||||
);
|
||||
assert!(matches!(
|
||||
validate_user_name("a/b"),
|
||||
Err(UserNameError::InvalidChar('/'))
|
||||
));
|
||||
assert!(matches!(
|
||||
validate_user_name("a b"),
|
||||
Err(UserNameError::InvalidChar(' '))
|
||||
));
|
||||
}
|
||||
|
||||
fn tempdir() -> tempfile::TempDir {
|
||||
|
||||
Reference in New Issue
Block a user