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;
|
use std::env;
|
||||||
|
|
||||||
fn get_argument() -> usize {
|
|
||||||
env::args()
|
|
||||||
.nth(1)
|
|
||||||
.and_then(|arg| arg.parse::<usize>().ok())
|
|
||||||
.unwrap_or_else(|| 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let num_pseudonyms = get_argument();
|
let num_pseudonyms = env::args()
|
||||||
let adjectives: Vec<&str> = include_str!("../data/adjectives.txt").lines().collect();
|
.nth(1)
|
||||||
let nouns: Vec<&str> = include_str!("../data/nouns.txt").lines().collect();
|
.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(|_| {
|
(0..num_pseudonyms).for_each(|_| {
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
|
||||||
format!(
|
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
&adjectives[fastrand::usize(0..adjectives.len())],
|
adjectives[fastrand::usize(0..adjectives.len())],
|
||||||
&nouns[fastrand::usize(0..nouns.len())],
|
nouns[fastrand::usize(0..nouns.len())],
|
||||||
fastrand::u32(0..1000)
|
fastrand::u32(0..1000)
|
||||||
)
|
);
|
||||||
)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user