feat: make it even simpler
This commit is contained in:
26
src/main.rs
26
src/main.rs
@@ -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())],
|
||||
adjectives[fastrand::usize(0..adjectives.len())],
|
||||
nouns[fastrand::usize(0..nouns.len())],
|
||||
fastrand::u32(0..1000)
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user