diff --git a/src/format/parse.rs b/src/format/parse.rs index 59c38cf..ab1e3d6 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -86,7 +86,7 @@ fn parse_rfc2822<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult<(&'a st s = s.trim_left(); if let Ok((s_, weekday)) = scan::short_weekday(s) { - if !s_.starts_with(",") { return Err(INVALID); } + if !s_.starts_with(',') { return Err(INVALID); } s = &s_[1..]; try!(parsed.set_weekday(weekday)); } @@ -177,7 +177,7 @@ fn parse_rfc3339<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult<(&'a st try!(parsed.set_minute(try_consume!(scan::number(s, 2, 2)))); s = try!(scan::char(s, b':')); try!(parsed.set_second(try_consume!(scan::number(s, 2, 2)))); - if s.starts_with(".") { + if s.starts_with('.') { let nanosecond = try_consume!(scan::nanosecond(&s[1..])); try!(parsed.set_nanosecond(nanosecond)); } @@ -252,10 +252,10 @@ pub fn parse<'a, I>(parsed: &mut Parsed, mut s: &str, items: I) -> ParseResult<( s = s.trim_left(); let v = if signed { - if s.starts_with("-") { + if s.starts_with('-') { let v = try_consume!(scan::number(&s[1..], 1, usize::MAX)); try!(0i64.checked_sub(v).ok_or(OUT_OF_RANGE)) - } else if s.starts_with("+") { + } else if s.starts_with('+') { try_consume!(scan::number(&s[1..], 1, usize::MAX)) } else { // if there is no explicit sign, we respect the original `width` @@ -303,7 +303,7 @@ pub fn parse<'a, I>(parsed: &mut Parsed, mut s: &str, items: I) -> ParseResult<( } Nanosecond | Nanosecond3 | Nanosecond6 | Nanosecond9=> { - if s.starts_with(".") { + if s.starts_with('.') { let nano = try_consume!(scan::nanosecond(&s[1..])); try!(parsed.set_nanosecond(nano)); } diff --git a/src/format/parsed.rs b/src/format/parsed.rs index 8b0aab2..3d40191 100644 --- a/src/format/parsed.rs +++ b/src/format/parsed.rs @@ -555,7 +555,7 @@ impl Parsed { /// Returns a parsed fixed time zone offset out of given fields. pub fn to_fixed_offset(&self) -> ParseResult { - self.offset.and_then(|offset| FixedOffset::east_opt(offset)).ok_or(OUT_OF_RANGE) + self.offset.and_then(FixedOffset::east_opt).ok_or(OUT_OF_RANGE) } /// Returns a parsed timezone-aware date and time out of given fields. diff --git a/src/format/scan.rs b/src/format/scan.rs index b456cca..4b6bbb0 100644 --- a/src/format/scan.rs +++ b/src/format/scan.rs @@ -252,7 +252,7 @@ pub fn timezone_offset_2822(s: &str) -> ParseResult<(&str, Option)> { } } else { let (s_, offset) = try!(timezone_offset(s, |s| Ok(s))); - if offset == 0 && s.starts_with("-") { // -0000 is not same to +0000 + if offset == 0 && s.starts_with('-') { // -0000 is not same to +0000 Ok((s_, None)) } else { Ok((s_, Some(offset))) diff --git a/src/naive/date.rs b/src/naive/date.rs index 7dd0960..85cde84 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -482,7 +482,7 @@ impl NaiveDate { /// ~~~~ #[inline] pub fn and_time(&self, time: NaiveTime) -> NaiveDateTime { - NaiveDateTime::new(self.clone(), time) + NaiveDateTime::new(*self, time) } /// Makes a new `NaiveDateTime` from the current date, hour, minute and second. @@ -884,7 +884,7 @@ impl NaiveDate { #[inline] pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { - DelayedFormat::new(Some(self.clone()), None, items) + DelayedFormat::new(Some(*self), None, items) } /// Formats the date with the specified format string. diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index d4a0573..c611f40 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -505,7 +505,7 @@ impl NaiveDateTime { #[inline] pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { - DelayedFormat::new(Some(self.date.clone()), Some(self.time.clone()), items) + DelayedFormat::new(Some(self.date), Some(self.time), items) } /// Formats the combined date and time with the specified format string. diff --git a/src/naive/time.rs b/src/naive/time.rs index 1082e7f..ec8f564 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -652,7 +652,7 @@ impl NaiveTime { #[inline] pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { - DelayedFormat::new(None, Some(self.clone()), items) + DelayedFormat::new(None, Some(*self), items) } /// Formats the time with the specified format string. diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index c9471c3..7300427 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -82,17 +82,17 @@ impl FixedOffset { impl TimeZone for FixedOffset { type Offset = FixedOffset; - fn from_offset(offset: &FixedOffset) -> FixedOffset { offset.clone() } + fn from_offset(offset: &FixedOffset) -> FixedOffset { *offset } fn offset_from_local_date(&self, _local: &NaiveDate) -> LocalResult { - LocalResult::Single(self.clone()) + LocalResult::Single(*self) } fn offset_from_local_datetime(&self, _local: &NaiveDateTime) -> LocalResult { - LocalResult::Single(self.clone()) + LocalResult::Single(*self) } - fn offset_from_utc_date(&self, _utc: &NaiveDate) -> FixedOffset { self.clone() } - fn offset_from_utc_datetime(&self, _utc: &NaiveDateTime) -> FixedOffset { self.clone() } + fn offset_from_utc_date(&self, _utc: &NaiveDate) -> FixedOffset { *self } + fn offset_from_utc_datetime(&self, _utc: &NaiveDateTime) -> FixedOffset { *self } } impl Offset for FixedOffset { diff --git a/src/offset/local.rs b/src/offset/local.rs index e31e23d..594b6c9 100644 --- a/src/offset/local.rs +++ b/src/offset/local.rs @@ -111,7 +111,7 @@ impl TimeZone for Local { // in the other words, we use the offset at the local midnight // but keep the actual date unaltered (much like `FixedOffset`). let midnight = self.from_local_datetime(&local.and_hms(0, 0, 0)); - midnight.map(|datetime| Date::from_utc(*local, datetime.offset().clone())) + midnight.map(|datetime| Date::from_utc(*local, *datetime.offset())) } fn from_local_datetime(&self, local: &NaiveDateTime) -> LocalResult> { let timespec = datetime_to_timespec(local, true); @@ -120,7 +120,7 @@ impl TimeZone for Local { fn from_utc_date(&self, utc: &NaiveDate) -> Date { let midnight = self.from_utc_datetime(&utc.and_hms(0, 0, 0)); - Date::from_utc(*utc, midnight.offset().clone()) + Date::from_utc(*utc, *midnight.offset()) } fn from_utc_datetime(&self, utc: &NaiveDateTime) -> DateTime { let timespec = datetime_to_timespec(utc, false); diff --git a/src/offset/mod.rs b/src/offset/mod.rs index 6037a1e..e0a102d 100644 --- a/src/offset/mod.rs +++ b/src/offset/mod.rs @@ -333,13 +333,13 @@ pub trait TimeZone: Sized + Clone { /// Converts the UTC `NaiveDate` to the local time. /// The UTC is continuous and thus this cannot fail (but can give the duplicate local time). fn from_utc_date(&self, utc: &NaiveDate) -> Date { - Date::from_utc(utc.clone(), self.offset_from_utc_date(utc)) + Date::from_utc(*utc, self.offset_from_utc_date(utc)) } /// Converts the UTC `NaiveDateTime` to the local time. /// The UTC is continuous and thus this cannot fail (but can give the duplicate local time). fn from_utc_datetime(&self, utc: &NaiveDateTime) -> DateTime { - DateTime::from_utc(utc.clone(), self.offset_from_utc_datetime(utc)) + DateTime::from_utc(*utc, self.offset_from_utc_datetime(utc)) } }