From e4bf1f0362d1cce71bbfa571ea3c37d1aa6017ce Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 14 Mar 2020 19:18:54 +0200 Subject: Apply suggestions by clippy --- src/main.rs | 7 +++---- src/partition.rs | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index dcffd70..bf0da95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use std::collections::LinkedList; mod partition; use partition::partition_days; -const USAGE: &'static str = " +const USAGE: &str = " Usage: frotate [-k|-d] [-b ] ... frotate --help @@ -49,9 +49,8 @@ fn main() { if args.flag_keep { for days in parts.iter() { - match days.front() { - Some(d) => print!("{:?} ", d), - None => {} + if let Some(d) = days.front() { + print!("{:?} ", d) } } println!(); diff --git a/src/partition.rs b/src/partition.rs index 8197112..46efeac 100644 --- a/src/partition.rs +++ b/src/partition.rs @@ -132,7 +132,7 @@ mod tests { } } -pub fn partition(f: &dyn Fn(u32) -> i64, v: &Vec) -> LinkedList> { +pub fn partition(f: &dyn Fn(u32) -> i64, v: &[i64]) -> LinkedList> { let mut term: LinkedList = LinkedList::new(); let mut res: LinkedList> = LinkedList::new(); let mut n: u32 = 1; @@ -154,7 +154,7 @@ pub fn partition(f: &dyn Fn(u32) -> i64, v: &Vec) -> LinkedList i64, - days: &Vec, + days: &[NaiveDate], ) -> LinkedList> { let day1 = days[0]; let part; @@ -171,10 +171,7 @@ pub fn partition_days( part = partition(f, &v); } - let res = part - .into_iter() + part.into_iter() .map(|l| l.into_iter().map(|d| day1 - Duration::days(d)).collect()) - .collect(); - - res + .collect() } -- cgit v1.2.3