commit 65810ef9d9e20690a0f746f52617ec050e4c2b4d
parent a14326bb9a7ac5d7f022da2859fb13edd2fea3fe
Author: Yuval Langer <yuval.langer@gmail.com>
Date: Thu, 7 Nov 2024 00:54:43 +0200
Apply suggestions made by `cargo clippy`.
Diffstat:
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/diceware_wordlists/build.rs b/diceware_wordlists/build.rs
@@ -1,4 +1,5 @@
use std::env;
+use std::fmt::Write as OtherWrite;
use std::fs::File;
use std::io::Read;
use std::io::Write;
@@ -25,8 +26,10 @@ fn make_diceware_wordlist(array_name: String) -> impl Fn(&str) -> String {
})
.collect::<String>()
})
- .map(|s| format!(" \"{}\",\n", s))
- .collect::<String>()
+ .fold(String::new(), |mut output, s| {
+ writeln!(output, " \"{}\",", s).unwrap();
+ output
+ })
+ "];\n\n"
}
}
@@ -36,8 +39,10 @@ fn make_minilock_wordlist(contents: &str) -> std::string::String {
"pub static MINILOCK_WORDLIST: [&str; 58110] = [\n".to_owned()
+ &contents[1023..543718]
.split(',')
- .map(|x| format!(" \"{}\",\n", x))
- .collect::<String>()
+ .fold(String::new(), |mut output, s| {
+ writeln!(output, " \"{}\",\n", s).unwrap();
+ output
+ })
+ "];\n"
}
@@ -48,8 +53,10 @@ fn make_eff_long_wordlist(contents: &str) -> String {
.split('\n')
.take(6 * 6 * 6 * 6 * 6)
.map(|x| x.split('\t').nth(1).unwrap())
- .map(|x| format!(" \"{}\",\n", x))
- .collect::<String>()
+ .fold(String::new(), |mut output, s| {
+ writeln!(output, " \"{}\",", s).unwrap();
+ output
+ })
+ "];\n"
}
@@ -61,8 +68,10 @@ fn make_eff_short_wordlist(array_name: String) -> impl Fn(&str) -> String {
.split('\n')
.take(6 * 6 * 6 * 6)
.map(|x| x.split('\t').nth(1).unwrap())
- .map(|x| format!(" \"{}\",\n", x))
- .collect::<String>()
+ .fold(String::new(), |mut output, x| {
+ writeln!(output, " \"{}\",", x).unwrap();
+ output
+ })
+ "];\n"
}
}