Merge pull request #98 from ijanos/clippy

Fix a few clippy warnings
This commit is contained in:
Kang Seonghoon 2016-10-02 18:49:13 +09:00 committed by GitHub
commit e308e8e929
9 changed files with 20 additions and 20 deletions

View File

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

View File

@ -555,7 +555,7 @@ impl Parsed {
/// Returns a parsed fixed time zone offset out of given fields.
pub fn to_fixed_offset(&self) -> ParseResult<FixedOffset> {
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.

View File

@ -252,7 +252,7 @@ pub fn timezone_offset_2822(s: &str) -> ParseResult<(&str, Option<i32>)> {
}
} 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)))

View File

@ -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<I>
where I: Iterator<Item=Item<'a>> + Clone {
DelayedFormat::new(Some(self.clone()), None, items)
DelayedFormat::new(Some(*self), None, items)
}
/// Formats the date with the specified format string.

View File

@ -505,7 +505,7 @@ impl NaiveDateTime {
#[inline]
pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I>
where I: Iterator<Item=Item<'a>> + 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.

View File

@ -652,7 +652,7 @@ impl NaiveTime {
#[inline]
pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I>
where I: Iterator<Item=Item<'a>> + Clone {
DelayedFormat::new(None, Some(self.clone()), items)
DelayedFormat::new(None, Some(*self), items)
}
/// Formats the time with the specified format string.

View File

@ -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<FixedOffset> {
LocalResult::Single(self.clone())
LocalResult::Single(*self)
}
fn offset_from_local_datetime(&self, _local: &NaiveDateTime) -> LocalResult<FixedOffset> {
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 {

View File

@ -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<DateTime<Local>> {
let timespec = datetime_to_timespec(local, true);
@ -120,7 +120,7 @@ impl TimeZone for Local {
fn from_utc_date(&self, utc: &NaiveDate) -> Date<Local> {
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<Local> {
let timespec = datetime_to_timespec(utc, false);

View File

@ -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<Self> {
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<Self> {
DateTime::from_utc(utc.clone(), self.offset_from_utc_datetime(utc))
DateTime::from_utc(*utc, self.offset_from_utc_datetime(utc))
}
}