use rand::seq::SliceRandom; pub struct TownNameGenerator { } impl TownNameGenerator { pub fn name() -> String { let first = include_str!("names/towns/first.txt").split("\n").collect::>(); let second = include_str!("names/towns/second.txt").split("\n").collect::>(); let mut rng = rand::thread_rng(); let first = first.choose(&mut rng).unwrap(); let second = second.choose(&mut rng).unwrap(); let name = format!("{}{}", first, second); // capitalize first letter name[0..1].to_uppercase() + &name[1..] } }