diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2019-10-06 10:36:40 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2019-10-06 10:36:40 +0200 |
commit | 81d131360d49282f6e3b9b9680071a17207cdee2 (patch) | |
tree | 9669b7e3f79965d136dd021257249399bc6621ad | |
parent | 5e50fa946f5ea89f1cbfcc3db8b232565f6a61f2 (diff) | |
download | frotate.rs-81d131360d49282f6e3b9b9680071a17207cdee2.tar.gz |
Reformat
-rw-r--r-- | src/lib.rs | 25 | ||||
-rw-r--r-- | src/main.rs | 5 |
2 files changed, 18 insertions, 12 deletions
@@ -5,11 +5,11 @@ use std::collections::LinkedList; use chrono::NaiveDate; use chrono::Duration; -pub fn partition (f: &Fn(u32) -> i64, v: &Vec<i64>) -> LinkedList<LinkedList<i64>> { +pub fn partition(f: &Fn(u32) -> i64, v: &Vec<i64>) -> LinkedList<LinkedList<i64>> { let mut term: LinkedList<i64> = LinkedList::new(); let mut res: LinkedList<LinkedList<i64>> = LinkedList::new(); - let mut n : u32 = 1; - let mut a : i64 = v[0]; + let mut n: u32 = 1; + let mut a: i64 = v[0]; for &i in v.iter() { while i >= a + f(n) { @@ -25,7 +25,10 @@ pub fn partition (f: &Fn(u32) -> i64, v: &Vec<i64>) -> LinkedList<LinkedList<i64 res } -pub fn partition_days (f: &Fn(u32) -> i64, days: &Vec<NaiveDate>) -> LinkedList<LinkedList<NaiveDate>> { +pub fn partition_days( + f: &Fn(u32) -> i64, + days: &Vec<NaiveDate>, +) -> LinkedList<LinkedList<NaiveDate>> { let day1 = days[0]; let part; @@ -33,7 +36,7 @@ pub fn partition_days (f: &Fn(u32) -> i64, days: &Vec<NaiveDate>) -> LinkedList< let mut v: Vec<i64> = Vec::with_capacity(days.len()); for &d in days.iter() { - v.push((day1-d).num_days()); + v.push((day1 - d).num_days()); } v.sort_unstable(); v.dedup(); @@ -41,10 +44,14 @@ pub fn partition_days (f: &Fn(u32) -> i64, days: &Vec<NaiveDate>) -> LinkedList< part = partition(f, &v); } - let res = part.into_iter().map( - |l| l.into_iter().map( - |d| day1 - Duration::days(d)).rev().collect() - ).collect(); + let res = part.into_iter() + .map(|l| { + l.into_iter() + .map(|d| day1 - Duration::days(d)) + .rev() + .collect() + }) + .collect(); res } diff --git a/src/main.rs b/src/main.rs index 8bf737a..752204c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,8 +30,8 @@ struct Args { arg_day: Vec<NaiveDate>, } -fn exponent(b:f32, n:u32) -> i64 { - let i : i32 = n as i32 - 1; +fn exponent(b: f32, n: u32) -> i64 { + let i: i32 = n as i32 - 1; b.powi(i).ceil() as i64 } @@ -67,4 +67,3 @@ fn main() { exit(1); } } - |