diff --git a/src/main.rs b/src/main.rs index d92f9cc..377ea33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,26 +1,20 @@ use std::env; -fn get_argument() -> usize { - env::args() - .nth(1) - .and_then(|arg| arg.parse::().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::>(); + let nouns = include_str!("../data/nouns.txt").lines().collect::>(); (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) + ); }); -} +} \ No newline at end of file