diff options
author | Joris | 2022-02-26 18:57:55 +0100 |
---|---|---|
committer | Joris | 2022-02-26 18:57:55 +0100 |
commit | f9f49285c5ecc76d3edfb0a54ffab53c2e296d7f (patch) | |
tree | f77f9b625446de7f0b9de1553fc52d702c4cbc69 /src/model | |
parent | 2d80413609130f1c121dcae39a150a27dd9f02ea (diff) |
Apply linter advices
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/event.rs | 8 | ||||
-rw-r--r-- | src/model/repetition.rs | 2 |
2 files changed, 5 insertions, 5 deletions
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<Event>, + events: &[Event], start: NaiveDate, end: NaiveDate, ) -> HashMap<NaiveDate, Vec<Event>> { let mut res: HashMap<NaiveDate, Vec<Event>> = 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<Option<NaiveTime>> { 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<u8> { let n = str.parse::<u8>().ok()?; - if n >= 1 && n <= 31 { + if (1..=31).contains(&n) { Some(n) } else { None |