fix linter

This commit is contained in:
Abraham Toriz 2022-05-07 23:37:30 +08:00
parent 713193f682
commit 9eea9af249
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
2 changed files with 8 additions and 8 deletions

View File

@ -155,7 +155,7 @@ mod tests {
assert_eq!(all_entries[1].note, Some("fake note".into()));
assert_eq!(all_entries[1].sheet, "default");
assert_eq!(Ps(&String::from_utf8_lossy(&streams.out)), Ps("Resuming \"fake note\" from entry #1
assert_eq!(Ps(&String::from_utf8_lossy(&streams.out)), Ps("Resuming \"fake note\"
Checked into sheet \"default\".\n"));
assert_eq!(Ps(&String::from_utf8_lossy(&streams.err)), Ps(""));
}

View File

@ -1,5 +1,5 @@
use std::io::{self, BufRead, Write};
use std::collections::HashMap;
use std::collections::{HashMap, hash_map};
use crate::io::Streams;
use crate::database::Database;
@ -41,7 +41,7 @@ fn to_choice(s: String) -> Choice {
} else {
Choice::Number(n)
}
} else if s == "" {
} else if s.is_empty() {
Choice::CtrlD
} else if s.to_lowercase() == "q" {
Choice::Quit
@ -64,18 +64,18 @@ where
entries
.into_iter().rev()
.filter_map(|e| e.note.map(|n| (n, e.start)))
.map(|(n, s)| if uniques.contains_key(&n) {
false
} else {
uniques.insert(n, s);
.map(|(n, s)| if let hash_map::Entry::Vacant(e) = uniques.entry(n) {
e.insert(s);
true
} else {
false
})
.filter(|&i| i)
.take(facts.config.interactive_entries)
.count();
let mut uniques: Vec<_> = uniques.into_iter().collect();
uniques.sort_unstable_by_key(|(_n, s)| s.clone());
uniques.sort_unstable_by_key(|(_n, s)| *s);
writeln!(streams.out, "Latest entries of sheet '{current_sheet}':\n")?;