From 55ace75b7de3eb125cbcd3e5885b65d33251e814 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Tue, 14 Jan 2025 17:20:36 +0100 Subject: [PATCH] Fix new clippy lint from 1.84.0 doesn't change MSRV --- src/history/file_backed.rs | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/history/file_backed.rs b/src/history/file_backed.rs index 4940c950..8a2d6151 100644 --- a/src/history/file_backed.rs +++ b/src/history/file_backed.rs @@ -62,24 +62,19 @@ impl History for FileBackedHistory { fn save(&mut self, h: HistoryItem) -> Result { let entry = h.command_line; // Don't append if the preceding value is identical or the string empty - let entry_id = if self - .entries - .back() - .map_or(true, |previous| previous != &entry) - && !entry.is_empty() - && self.capacity > 0 - { - if self.entries.len() == self.capacity { - // History is "full", so we delete the oldest entry first, - // before adding a new one. - self.entries.pop_front(); - self.len_on_disk = self.len_on_disk.saturating_sub(1); - } - self.entries.push_back(entry.to_string()); - Some(HistoryItemId::new((self.entries.len() - 1) as i64)) - } else { - None - }; + let entry_id = + if (self.entries.back() != Some(&entry)) && !entry.is_empty() && self.capacity > 0 { + if self.entries.len() == self.capacity { + // History is "full", so we delete the oldest entry first, + // before adding a new one. + self.entries.pop_front(); + self.len_on_disk = self.len_on_disk.saturating_sub(1); + } + self.entries.push_back(entry.to_string()); + Some(HistoryItemId::new((self.entries.len() - 1) as i64)) + } else { + None + }; Ok(FileBackedHistory::construct_entry(entry_id, entry)) }