From d85ca7564fe4d41659a37799b65155eee22aaf38 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 2 Mar 2015 11:50:03 +0000 Subject: [PATCH] Remove old closure kind syntax --- src/datetime.rs | 2 +- src/format/mod.rs | 4 ++-- src/format/strftime.rs | 4 ++-- src/naive/date.rs | 18 +++++++++--------- src/naive/datetime.rs | 4 ++-- src/naive/time.rs | 6 +++--- src/offset/local.rs | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/datetime.rs b/src/datetime.rs index 12c0687..35a0d0f 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -461,7 +461,7 @@ mod tests { #[test] fn test_datetime_parse_from_str() { - let ymdhms = |&: y,m,d,h,n,s,off| FixedOffset::east(off).ymd(y,m,d).and_hms(h,n,s); + let ymdhms = |y,m,d,h,n,s,off| FixedOffset::east(off).ymd(y,m,d).and_hms(h,n,s); assert_eq!(DateTime::parse_from_str("2014-5-7T12:34:56+09:30", "%Y-%m-%dT%H:%M:%S%z"), Ok(ymdhms(2014, 5, 7, 12, 34, 56, 570*60))); // ignore offset assert!(DateTime::parse_from_str("20140507000000", "%Y%m%d%H%M%S").is_err()); // no offset diff --git a/src/format/mod.rs b/src/format/mod.rs index 9209866..196e128 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -259,9 +259,9 @@ pub fn format<'a, I>(w: &mut fmt::Formatter, date: Option<&NaiveDate>, time: Opt use self::Numeric::*; let week_from_sun = - |&: d: &NaiveDate| (d.ordinal() - d.weekday().num_days_from_sunday() + 7) / 7; + |d: &NaiveDate| (d.ordinal() - d.weekday().num_days_from_sunday() + 7) / 7; let week_from_mon = - |&: d: &NaiveDate| (d.ordinal() - d.weekday().num_days_from_monday() + 7) / 7; + |d: &NaiveDate| (d.ordinal() - d.weekday().num_days_from_monday() + 7) / 7; let (width, v) = match spec { Year => (4, date.map(|d| d.year() as i64)), diff --git a/src/format/strftime.rs b/src/format/strftime.rs index 4cbf729..9193b36 100644 --- a/src/format/strftime.rs +++ b/src/format/strftime.rs @@ -216,7 +216,7 @@ impl<'a> Iterator for StrftimeItems<'a> { // the next item is space Some((c, _)) if c.is_whitespace() => { // `%` is not a whitespace, so `c != '%'` is redundant - let nextspec = self.remainder.find(|&: c: char| !c.is_whitespace()) + let nextspec = self.remainder.find(|c: char| !c.is_whitespace()) .unwrap_or(self.remainder.len()); assert!(nextspec > 0); let item = sp!(&self.remainder[..nextspec]); @@ -226,7 +226,7 @@ impl<'a> Iterator for StrftimeItems<'a> { // the next item is literal _ => { - let nextspec = self.remainder.find(|&: c: char| c.is_whitespace() || c == '%') + let nextspec = self.remainder.find(|c: char| c.is_whitespace() || c == '%') .unwrap_or(self.remainder.len()); assert!(nextspec > 0); let item = lit!(&self.remainder[..nextspec]); diff --git a/src/naive/date.rs b/src/naive/date.rs index 3c3c5d1..5e1f12d 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -536,7 +536,7 @@ mod tests { #[test] fn test_date_from_ymd() { - let ymd_opt = |&: y,m,d| NaiveDate::from_ymd_opt(y, m, d); + let ymd_opt = |y,m,d| NaiveDate::from_ymd_opt(y, m, d); assert!(ymd_opt(2012, 0, 1).is_none()); assert!(ymd_opt(2012, 1, 1).is_some()); @@ -552,8 +552,8 @@ mod tests { #[test] fn test_date_from_yo() { - let yo_opt = |&: y,o| NaiveDate::from_yo_opt(y, o); - let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d); + let yo_opt = |y,o| NaiveDate::from_yo_opt(y, o); + let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d); assert_eq!(yo_opt(2012, 0), None); assert_eq!(yo_opt(2012, 1), Some(ymd(2012, 1, 1))); @@ -582,8 +582,8 @@ mod tests { #[test] fn test_date_from_isoywd() { - let isoywd_opt = |&: y,w,d| NaiveDate::from_isoywd_opt(y, w, d); - let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d); + let isoywd_opt = |y,w,d| NaiveDate::from_isoywd_opt(y, w, d); + let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d); assert_eq!(isoywd_opt(2004, 0, Weekday::Sun), None); assert_eq!(isoywd_opt(2004, 1, Weekday::Mon), Some(ymd(2003, 12, 29))); @@ -645,7 +645,7 @@ mod tests { #[test] fn test_date_from_num_days_from_ce() { - let from_ndays_from_ce = |&: days| NaiveDate::from_num_days_from_ce_opt(days); + let from_ndays_from_ce = |days| NaiveDate::from_num_days_from_ce_opt(days); assert_eq!(from_ndays_from_ce(1), Some(NaiveDate::from_ymd(1, 1, 1))); assert_eq!(from_ndays_from_ce(2), Some(NaiveDate::from_ymd(1, 1, 2))); assert_eq!(from_ndays_from_ce(31), Some(NaiveDate::from_ymd(1, 1, 31))); @@ -772,7 +772,7 @@ mod tests { #[test] fn test_date_succ() { - let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d); + let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d); assert_eq!(ymd(2014, 5, 6).succ_opt(), Some(ymd(2014, 5, 7))); assert_eq!(ymd(2014, 5, 31).succ_opt(), Some(ymd(2014, 6, 1))); assert_eq!(ymd(2014, 12, 31).succ_opt(), Some(ymd(2015, 1, 1))); @@ -782,7 +782,7 @@ mod tests { #[test] fn test_date_pred() { - let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d); + let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d); assert_eq!(ymd(2016, 3, 1).pred_opt(), Some(ymd(2016, 2, 29))); assert_eq!(ymd(2015, 1, 1).pred_opt(), Some(ymd(2014, 12, 31))); assert_eq!(ymd(2014, 6, 1).pred_opt(), Some(ymd(2014, 5, 31))); @@ -903,7 +903,7 @@ mod tests { #[test] fn test_date_parse_from_str() { - let ymd = |&: y,m,d| NaiveDate::from_ymd(y,m,d); + let ymd = |y,m,d| NaiveDate::from_ymd(y,m,d); assert_eq!(NaiveDate::parse_from_str("2014-5-7T12:34:56+09:30", "%Y-%m-%dT%H:%M:%S%z"), Ok(ymd(2014, 5, 7))); // ignore time and offset assert_eq!(NaiveDate::parse_from_str("2015-W06-1=2015-033", "%G-W%V-%u = %Y-%j"), diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index 9838200..33663f7 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -372,7 +372,7 @@ mod tests { #[test] fn test_datetime_sub() { - let ymdhms = |&: y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s); + let ymdhms = |y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s); assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) - ymdhms(2014, 5, 6, 7, 8, 9), Duration::zero()); assert_eq!(ymdhms(2014, 5, 6, 7, 8, 10) - ymdhms(2014, 5, 6, 7, 8, 9), Duration::seconds(1)); @@ -434,7 +434,7 @@ mod tests { #[test] fn test_datetime_parse_from_str() { - let ymdhms = |&: y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s); + let ymdhms = |y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s); assert_eq!(NaiveDateTime::parse_from_str("2014-5-7T12:34:56+09:30", "%Y-%m-%dT%H:%M:%S%z"), Ok(ymdhms(2014, 5, 7, 12, 34, 56))); // ignore offset assert_eq!(NaiveDateTime::parse_from_str("2015-W06-1 000000", "%G-W%V-%u%H%M%S"), diff --git a/src/naive/time.rs b/src/naive/time.rs index ea51318..26fb168 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -355,7 +355,7 @@ mod tests { //assert_eq!(rhs + lhs, sum); } - let hmsm = |&: h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi); + let hmsm = |h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi); check(hmsm(3, 5, 7, 900), Duration::zero(), hmsm(3, 5, 7, 900)); check(hmsm(3, 5, 7, 900), Duration::milliseconds(100), hmsm(3, 5, 8, 0)); @@ -373,7 +373,7 @@ mod tests { assert_eq!(rhs - lhs, -diff); } - let hmsm = |&: h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi); + let hmsm = |h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi); check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 900), Duration::zero()); check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 600), Duration::milliseconds(300)); @@ -448,7 +448,7 @@ mod tests { #[test] fn test_time_parse_from_str() { - let hms = |&: h,m,s| NaiveTime::from_hms(h,m,s); + let hms = |h,m,s| NaiveTime::from_hms(h,m,s); assert_eq!(NaiveTime::parse_from_str("2014-5-7T12:34:56+09:30", "%Y-%m-%dT%H:%M:%S%z"), Ok(hms(12, 34, 56))); // ignore date and offset assert_eq!(NaiveTime::parse_from_str("PM 12:59", "%P %H:%M"), diff --git a/src/offset/local.rs b/src/offset/local.rs index 6cf1ec3..2a74d85 100644 --- a/src/offset/local.rs +++ b/src/offset/local.rs @@ -80,10 +80,10 @@ impl TimeZone for Local { // they are easier to define in terms of the finished date and time unlike other offsets fn offset_from_local_date(&self, local: &NaiveDate) -> LocalResult { - self.from_local_date(local).map(|&: date| *date.offset()) + self.from_local_date(local).map(|date| *date.offset()) } fn offset_from_local_datetime(&self, local: &NaiveDateTime) -> LocalResult { - self.from_local_datetime(local).map(|&: datetime| *datetime.offset()) + self.from_local_datetime(local).map(|datetime| *datetime.offset()) } fn offset_from_utc_date(&self, utc: &NaiveDate) -> FixedOffset {