Finish refactoring

This commit is contained in:
2025-08-10 21:15:53 -03:00
parent f123282699
commit a004fe2308
50 changed files with 2639 additions and 587 deletions
+25
View File
@@ -1,3 +1,6 @@
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng;
pub trait ToTitleCase {
fn to_title_case(&self) -> String;
}
@@ -6,6 +9,10 @@ impl<T> ToTitleCase for T
where
T: ToString,
{
/// Removes duplicated whitespaces and capitalizes the first letter of each word.
///
/// Returns:
/// [`String`] - The title-cased version of the string.
fn to_title_case(&self) -> String {
self.to_string()
.split_whitespace()
@@ -20,3 +27,21 @@ where
.join(" ")
}
}
/// Returns a random `u64` generated using a cryptographically secure random number generator.
///
/// Returns:
/// [`u64`] - A randomly generated 64-bit unsigned integer.
pub fn get_random_u64() -> u64 {
let mut rng = ChaCha20Rng::from_os_rng();
rng.random()
}
pub trait Bye: Sized {
/// Whatever the value is, it consumes it and returns a unit value. Used to remove warnings
/// about unused results.
fn bye(self) {}
}
impl<T> Bye for T {}