From 81d131360d49282f6e3b9b9680071a17207cdee2 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sun, 6 Oct 2019 10:36:40 +0200 Subject: Reformat --- src/lib.rs | 25 ++++++++++++++++--------- src/main.rs | 5 ++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bf48d04..9da8631 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,11 +5,11 @@ use std::collections::LinkedList; use chrono::NaiveDate; use chrono::Duration; -pub fn partition (f: &Fn(u32) -> i64, v: &Vec) -> LinkedList> { +pub fn partition(f: &Fn(u32) -> i64, v: &Vec) -> LinkedList> { let mut term: LinkedList = LinkedList::new(); let mut res: LinkedList> = 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) -> LinkedList i64, days: &Vec) -> LinkedList> { +pub fn partition_days( + f: &Fn(u32) -> i64, + days: &Vec, +) -> LinkedList> { let day1 = days[0]; let part; @@ -33,7 +36,7 @@ pub fn partition_days (f: &Fn(u32) -> i64, days: &Vec) -> LinkedList< let mut v: Vec = 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) -> 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, } -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); } } - -- cgit v1.2.3