Add documentation for utils.rs

This commit is contained in:
2025-08-13 00:21:41 -03:00
parent 80ed00f796
commit 66584a8239
+9
View File
@@ -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::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng; 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 { pub trait ToTitleCase {
fn to_title_case(&self) -> String; fn to_title_case(&self) -> String;
} }
@@ -38,6 +45,8 @@ pub fn get_random_u64() -> u64 {
rng.random() 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 { pub trait Bye: Sized {
/// Whatever the value is, it consumes it and returns a unit value. Used to remove warnings /// Whatever the value is, it consumes it and returns a unit value. Used to remove warnings
/// about unused results. /// about unused results.