From 14b24e75858af48f39d5880e7f6c9adeac1b1da9 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Sat, 2 Mar 2024 13:05:15 +0100 Subject: [PATCH] refactor: clippy::if_not_else (#974) --- Cargo.toml | 1 + src/widgets/calendar.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce5c0be8..4fe38d74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ doc_markdown = "warn" empty_line_after_doc_comments = "warn" equatable_if_let = "warn" explicit_iter_loop = "warn" +if_not_else = "warn" implicit_clone = "warn" inefficient_to_string = "warn" items_after_statements = "warn" diff --git a/src/widgets/calendar.rs b/src/widgets/calendar.rs index 094a4cfd..945ff93e 100644 --- a/src/widgets/calendar.rs +++ b/src/widgets/calendar.rs @@ -99,7 +99,12 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> { /// All logic to style a date goes here. fn format_date(&self, date: Date) -> Span { - if date.month() != self.display_date.month() { + if date.month() == self.display_date.month() { + Span::styled( + format!("{:2?}", date.day()), + self.default_style.patch(self.events.get_style(date)), + ) + } else { match self.show_surrounding { None => Span::styled(" ", self.default_bg()), Some(s) => { @@ -110,11 +115,6 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> { Span::styled(format!("{:2?}", date.day()), style) } } - } else { - Span::styled( - format!("{:2?}", date.day()), - self.default_style.patch(self.events.get_style(date)), - ) } } }