rusty-diceware

Commandline diceware, with or without dice, written in Rustlang.
git clone https://kaka.farm/~git/rusty-diceware
Log | Files | Refs | README | LICENSE

commit 5a87dc62b8087a55f538891ebf680e4d85b1b7eb
parent 65810ef9d9e20690a0f746f52617ec050e4c2b4d
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Thu,  7 Nov 2024 04:45:39 +0200

Move entropy printing outside of the two word generation cases according to DRY.

Diffstat:
Msrc/main.rs | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -286,6 +286,7 @@ fn main() { } else { wordlist_name.get_list().to_vec() }; + let mut words_count = 0; if is_physical_rolls { let stdin = stdin(); @@ -296,16 +297,13 @@ fn main() { if let Some(word) = words.next() { print!("{}", word); - let words_count = 1; + words_count = 1; for word in words { print!("{}{}", delimiter, word); + words_count += 1; } println!(); - - if is_entropy_printed { - println!("{}", entropyn(wordlist, words_count)); - } }; } else if word_num != 0 { let mut rng = thread_rng(); @@ -314,7 +312,7 @@ fn main() { print!("{}", words.next().unwrap()); - let mut words_count = 1; + words_count = 1; for _ in 1..word_num { print!("{}{}", delimiter, words.next().unwrap()); @@ -322,14 +320,14 @@ fn main() { } println!(); - - if is_entropy_printed { - println!("{}", entropyn(wordlist, words_count)); - } } else { print_usage(program, opts); exit(-1); }; + + if is_entropy_printed { + println!("{}", entropyn(wordlist, words_count)); + } } #[cfg(test)]