Add documentation for utils.rs
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user