1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/// Random trait allows a common way to generate
/// some random struct, usually for testing purposes.
///
/// ## Examples
/// ```
/// use cs_utils::traits::Random;
/// use cs_utils::{random_number, random_str};
///
/// #[derive(Debug)]
/// struct SomeStruct {
/// id: u16,
/// name: String,
/// }
///
/// impl Random for SomeStruct {
/// fn random() -> Self {
/// return SomeStruct {
/// id: random_number(0..=u16::MAX),
/// name: random_str(10),
/// };
/// }
/// }
///
/// let random_struct = SomeStruct::random();
/// println!("{:?}", &random_struct);
/// ```
pub trait Random {
fn random() -> Self;
}