1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use rand::distributions::Alphanumeric;
use rand::Rng;
use rand::RngCore;

pub type Random = Box<dyn RngCore>;

pub fn make_random() -> Random {
    use rand_xoshiro::rand_core::SeedableRng;
    use rand_xoshiro::Xoshiro256PlusPlus;
    Box::new(Xoshiro256PlusPlus::seed_from_u64(82938))
}

pub fn make_random_string(random: &mut Random, length: usize) -> String {
    random
        .sample_iter(&Alphanumeric)
        .take(length)
        .map(char::from)
        .collect::<String>()
}