Satisfy clippy

This commit is contained in:
Joscha 2022-05-02 12:57:21 +02:00
parent f42cf01a15
commit 972a590ba9
3 changed files with 4 additions and 6 deletions

View file

@ -189,7 +189,7 @@ impl DayLayout {
} }
} }
fn sort_entries(entries: &mut Vec<(usize, &Entry)>) { fn sort_entries(entries: &mut [(usize, &Entry)]) {
// Entries should be sorted by these factors, in descending order of // Entries should be sorted by these factors, in descending order of
// significance: // significance:
// 1. Their start date, if any // 1. Their start date, if any
@ -219,7 +219,7 @@ impl DayLayout {
entries.sort_by_key(|(_, e)| e.dates.map(|d| d.sorted().root_with_time())); entries.sort_by_key(|(_, e)| e.dates.map(|d| d.sorted().root_with_time()));
} }
fn sort_day(day: &mut Vec<DayEntry>) { fn sort_day(day: &mut [DayEntry]) {
// In a day, entries should be sorted into these categories: // In a day, entries should be sorted into these categories:
// 1. Untimed entries that end at the current day // 1. Untimed entries that end at the current day
// 2. Timed entries, based on // 2. Timed entries, based on

View file

@ -174,9 +174,7 @@ impl LineLayout {
self.line_entry(entries, *i, today, Times::At(*t), None); self.line_entry(entries, *i, today, Times::At(*t), None);
} }
DayEntry::TimedAt(i, t, t2) => { DayEntry::TimedAt(i, t, t2) => {
let time = t2 let time = t2.map(|t2| Times::FromTo(*t, t2)).unwrap_or(Times::At(*t));
.map(|t2| Times::FromTo(*t, t2))
.unwrap_or_else(|| Times::At(*t));
self.line_entry(entries, *i, today, time, None); self.line_entry(entries, *i, today, time, None);
} }
DayEntry::TimedStart(i, t) => { DayEntry::TimedStart(i, t) => {

View file

@ -319,7 +319,7 @@ impl fmt::Display for Command {
} }
impl File { impl File {
fn sort(commands: &mut Vec<&Command>) { fn sort(commands: &mut [&Command]) {
// Order of commands in a file: // Order of commands in a file:
// 1. Imports, sorted alphabetically // 1. Imports, sorted alphabetically
// 2. Time zone(s) // 2. Time zone(s)