Stop using clone() on Copy types

https://github.com/Manishearth/rust-clippy/wiki#clone_on_copy
This commit is contained in:
János Illés 2016-10-02 00:56:37 +02:00
parent 6cc5d18696
commit 076a54532f
6 changed files with 13 additions and 13 deletions

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