diff --git a/src/utils.rs b/src/utils.rs index 0b7d7e9..1238cd8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,13 @@ +//! A set of generic utilities used across the codebase. +//! +//! It currently includes [`ToTitleCase`], [`get_random_u64`], and [`Bye`]. + use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha20Rng; +/// Converts a string to title case. +/// +/// It removes all duplicate whitespaces and capitalizes the first letter of every word. pub trait ToTitleCase { fn to_title_case(&self) -> String; } @@ -38,6 +45,8 @@ pub fn get_random_u64() -> u64 { rng.random() } +/// Consumes any value. Used to normalize return values when the output of a function doesn't +/// matter yet all functions being called return different types. pub trait Bye: Sized { /// Whatever the value is, it consumes it and returns a unit value. Used to remove warnings /// about unused results.