fmt
parent
27a6c614d5
commit
cdf233619f
12
src/lib.rs
12
src/lib.rs
|
@ -22,20 +22,20 @@ impl Default for Dice {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let wordlist = include_str!("eff_short_wordlist_1.txt");
|
let wordlist = include_str!("eff_short_wordlist_1.txt");
|
||||||
let words: Vec<_> = wordlist.split('\n').map(|s| s.to_string()).collect();
|
let words: Vec<_> = wordlist.split('\n').map(|s| s.to_string()).collect();
|
||||||
|
|
||||||
assert_eq!(words.len(), 1253);
|
assert_eq!(words.len(), 1253);
|
||||||
assert_eq!(words[0], "acid");
|
assert_eq!(words[0], "acid");
|
||||||
assert_eq!(words[600], "large");
|
assert_eq!(words[600], "large");
|
||||||
assert_eq!(words[1252], "zoom");
|
assert_eq!(words[1252], "zoom");
|
||||||
|
|
||||||
Self {
|
Self { words }
|
||||||
words,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dice {
|
impl Dice {
|
||||||
pub fn pick_word(&self) -> &str {
|
pub fn pick_word(&self) -> &str {
|
||||||
self.words.choose(&mut rand::thread_rng ()).expect("`choose` should always return `Some`")
|
self.words
|
||||||
|
.choose(&mut rand::thread_rng())
|
||||||
|
.expect("`choose` should always return `Some`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue