diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2020-03-14 19:18:54 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2020-03-14 19:18:54 +0200 |
commit | e4bf1f0362d1cce71bbfa571ea3c37d1aa6017ce (patch) | |
tree | 649ce373f88b68372d9e3ddfbb3b0a908dfce113 /src | |
parent | 8827326908d52ec68e563e396c8deab83d3c73c7 (diff) | |
download | frotate.rs-e4bf1f0362d1cce71bbfa571ea3c37d1aa6017ce.tar.gz |
Apply suggestions by clippy
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 7 | ||||
-rw-r--r-- | src/partition.rs | 11 |
2 files changed, 7 insertions, 11 deletions
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 <base>] <day>... 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<i64>) -> LinkedList<LinkedList<i64>> { +pub fn partition(f: &dyn Fn(u32) -> i64, v: &[i64]) -> LinkedList<LinkedList<i64>> { let mut term: LinkedList<i64> = LinkedList::new(); let mut res: LinkedList<LinkedList<i64>> = LinkedList::new(); let mut n: u32 = 1; @@ -154,7 +154,7 @@ pub fn partition(f: &dyn Fn(u32) -> i64, v: &Vec<i64>) -> LinkedList<LinkedList< pub fn partition_days( f: &dyn Fn(u32) -> i64, - days: &Vec<NaiveDate>, + days: &[NaiveDate], ) -> LinkedList<LinkedList<NaiveDate>> { 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() } |