siranga/src/animals.rs
2025-04-04 16:13:11 +02:00

15 lines
364 B
Rust

use std::sync::LazyLock;
use rand::{rngs::OsRng, seq::SliceRandom};
pub fn get_animal_name() -> &'static str {
static ANIMALS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
let animals = include_str!("./animals.txt");
animals.lines().collect()
});
ANIMALS
.choose(&mut OsRng)
.expect("List should not be empty")
}