use fake::{Fake, Faker}; use rand::distributions; use rand::rngs::StdRng; use rand::SeedableRng; fn main() { // generate random u8 println!("u8 ({}) in [MIN, MAX)", Faker.fake::()); // generate random u8 using range println!("u8 ({}) in [3,7)", (3..7).fake::()); println!("u8 ({}) in [3,7]", (3..=7).fake::()); println!("u8 ({}) in [3, MAX]", (3..).fake::()); println!("u8 ({}) in [MIN, 7)", (..7).fake::()); println!("u8 ({}) in [MIN, 7]", (..=7).fake::()); println!("u8 ({}) in [MIN, MAX]", (..).fake::()); // to reuse sampler `Uniform` for value generation let sampler = distributions::Uniform::new_inclusive(1, 10); for _ in 0..5 { let v: usize = sampler.fake(); println!("sample value {}", v); } // fixed seed rng let seed = [ 1, 0, 0, 0, 23, 0, 0, 0, 200, 1, 0, 0, 210, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]; let rng = &mut StdRng::from_seed(seed); println!("{:?}", Faker.fake_with_rng::(rng)); println!("{:?}", (1..8).fake_with_rng::(rng)); for _ in 0..5 { let v: usize = sampler.fake_with_rng(rng); println!("sample value from fixed seed {}", v); } }