rusty-diceware

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4070f7f53c15c1eb25eb0274ef0a292ae6821f4c
parent 0d91617cc5db7d22a012f7c6abe1aa2c51b144a1
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date:   Fri,  9 Sep 2022 17:14:11 +0300

Use a more general function argument type.

Diffstat:
Msrc/bin/diceware.rs | 10+++++-----
Msrc/lib.rs | 4++--
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/bin/diceware.rs b/src/bin/diceware.rs @@ -76,10 +76,10 @@ fn main() { .split('\n') .map(|x| x.trim()) .filter(|x| x != &"") - .collect(); + .collect::<Vec<&str>>(); print_words( - wordlist, + &wordlist, &word_num, &delimiter, &is_entropy_printed, @@ -87,7 +87,7 @@ fn main() { ); } else if matches.opt_present("reinhold") { print_words( - REINHOLD_WORDLIST.to_vec(), + REINHOLD_WORDLIST.as_ref(), &word_num, &delimiter, &is_entropy_printed, @@ -95,7 +95,7 @@ fn main() { ); } else if matches.opt_present("beale") { print_words( - BEALE_WORDLIST.to_vec(), + BEALE_WORDLIST.as_ref(), &word_num, &delimiter, &is_entropy_printed, @@ -103,7 +103,7 @@ fn main() { ); } else { print_words( - MINILOCK_WORDLIST.to_vec(), + MINILOCK_WORDLIST.as_ref(), &word_num, &delimiter, &is_entropy_printed, diff --git a/src/lib.rs b/src/lib.rs @@ -19,7 +19,7 @@ fn entropyn(wordlist: &[&str], n: u64) -> f64 { } pub fn print_words( - wordlist: Vec<&str>, + wordlist: &[&str], word_num: &u64, delimiter: &char, is_entropy_printed: &bool, @@ -34,7 +34,7 @@ pub fn print_words( println!(); if *is_entropy_printed { - println!("{}", entropyn(&wordlist, *word_num)) + println!("{}", entropyn(wordlist, *word_num)) } }