Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions src/format/strftime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down
18 changes: 9 additions & 9 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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)));
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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)));
Expand All @@ -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)));
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions src/naive/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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"),
Expand Down
6 changes: 3 additions & 3 deletions src/naive/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions src/offset/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down