From f9f49285c5ecc76d3edfb0a54ffab53c2e296d7f Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 26 Feb 2022 18:57:55 +0100 Subject: Apply linter advices --- src/model/event.rs | 8 ++++---- src/model/repetition.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/model') diff --git a/src/model/event.rs b/src/model/event.rs index b18d811..249d077 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -46,16 +46,16 @@ impl Event { /// Repeated events in an included date range pub fn repetitions_between( - events: &Vec, + events: &[Event], start: NaiveDate, end: NaiveDate, ) -> HashMap> { let mut res: HashMap> = HashMap::new(); for event in events { - for repetition in event.repetition.as_ref() { + if let Some(repetition) = &event.repetition { for date in repetition.between(event.date, start, end) { - res.entry(date).or_insert(vec![]).push(event.clone()) + res.entry(date).or_insert_with(Vec::new).push(event.clone()) } } } @@ -117,7 +117,7 @@ fn validate_time(time: String) -> Option> { if time.is_empty() { Some(None) } else { - parse_time(time).map(|t| Some(t)) + parse_time(time).map(Some) } } diff --git a/src/model/repetition.rs b/src/model/repetition.rs index ceb903b..d21dd70 100644 --- a/src/model/repetition.rs +++ b/src/model/repetition.rs @@ -16,7 +16,7 @@ pub enum DayOfMonth { pub fn validate_day(str: &str) -> Option { let n = str.parse::().ok()?; - if n >= 1 && n <= 31 { + if (1..=31).contains(&n) { Some(n) } else { None -- cgit v1.2.3