1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use rand::prelude::*;

pub fn generate(rng: &mut impl Rng) -> String {
    let starts = ["ad", "tr", "b", "l", "p", "d", "r", "w", "t", "fr", "s"];
    let vowels = ["o", "e", "a", "i"];
    let cons = ["m", "d", "st", "n", "y", "gh", "s"];

    let mut name = String::new();

    name += starts.choose(rng).unwrap();

    for _ in 0..rng.gen_range(1..=3) {
        name += vowels.choose(rng).unwrap();
        name += cons.choose(rng).unwrap();
    }

    // Make the first letter uppercase (hacky)
    name.chars()
        .enumerate()
        .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c })
        .collect()
}