kanji_info example: simplify using .inspect()

main
Stefan Majewsky 2 years ago
parent a709995cef
commit e26e3b05cb

@ -6,8 +6,8 @@
fn main() { fn main() {
let input = "一日"; let input = "一日";
let count = jmdict::entries() let count = jmdict::entries()
.filter(|e| { .filter(|e| e.kanji_elements().any(|k| k.text == input))
if e.kanji_elements().any(|k| k.text == input) { .inspect(|e| {
// note two entries have identical Kanji // note two entries have identical Kanji
// yet differ in reading // yet differ in reading
println!("--- entry #{} ---", e.number); println!("--- entry #{} ---", e.number);
@ -24,10 +24,6 @@ fn main() {
println!("info: {:?}", info); println!("info: {:?}", info);
} }
} }
return true
}
false
}) })
.count(); .count();
println!("{} entries for {}", count, input); println!("{} entries for {}", count, input);

Loading…
Cancel
Save