cs_utils/traits/
random.rs

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