feat: make it even simpler

This commit is contained in:
2025-04-05 14:33:02 +02:00
parent 6d9a5bbb84
commit f5b2737178

View File

@@ -1,26 +1,20 @@
use std::env;
fn get_argument() -> usize {
env::args()
.nth(1)
.and_then(|arg| arg.parse::<usize>().ok())
.unwrap_or_else(|| 10)
}
fn main() {
let num_pseudonyms = get_argument();
let adjectives: Vec<&str> = include_str!("../data/adjectives.txt").lines().collect();
let nouns: Vec<&str> = include_str!("../data/nouns.txt").lines().collect();
let num_pseudonyms = env::args()
.nth(1)
.and_then(|arg| arg.parse().ok())
.unwrap_or(10);
let adjectives = include_str!("../data/adjectives.txt").lines().collect::<Vec<_>>();
let nouns = include_str!("../data/nouns.txt").lines().collect::<Vec<_>>();
(0..num_pseudonyms).for_each(|_| {
println!(
"{}",
format!(
"{}-{}-{}",
&adjectives[fastrand::usize(0..adjectives.len())],
&nouns[fastrand::usize(0..nouns.len())],
fastrand::u32(0..1000)
)
)
"{}-{}-{}",
adjectives[fastrand::usize(0..adjectives.len())],
nouns[fastrand::usize(0..nouns.len())],
fastrand::u32(0..1000)
);
});
}
}