Remove old closure kind syntax

This commit is contained in:
Dan 2015-03-02 11:50:03 +00:00
parent 2dbc11dcb1
commit d85ca7564f
7 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -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)),

View File

@ -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]);

View File

@ -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"),

View File

@ -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"),

View File

@ -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"),

View File

@ -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<FixedOffset> {
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<FixedOffset> {
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 {