Skip to content

Implement Clone and DeepClone for extra::time::{Tm, Timespec} #8555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub mod rustrt {
}

/// A record specifying a time value in seconds and nanoseconds.
#[deriving(Eq, Encodable, Decodable)]
#[deriving(Clone, DeepClone, Eq, Encodable, Decodable)]
pub struct Timespec { sec: i64, nsec: i32 }

/*
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn tzset() {
}
}

#[deriving(Eq, Encodable, Decodable)]
#[deriving(Clone, DeepClone, Eq, Encodable, Decodable)]
pub struct Tm {
tm_sec: i32, // seconds after the minute ~[0-60]
tm_min: i32, // minutes after the hour ~[0-59]
Expand Down
16 changes: 15 additions & 1 deletion src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use at_vec;
use cast;
use char;
use char::Char;
use clone::Clone;
use clone::{Clone, DeepClone};
use container::{Container, Mutable};
use iter::Times;
use iterator::{Iterator, FromIterator, Extendable};
Expand Down Expand Up @@ -2104,13 +2104,27 @@ impl Clone for ~str {
}
}

impl DeepClone for ~str {
#[inline]
fn deep_clone(&self) -> ~str {
self.to_owned()
}
}

impl Clone for @str {
#[inline]
fn clone(&self) -> @str {
*self
}
}

impl DeepClone for @str {
#[inline]
fn deep_clone(&self) -> @str {
*self
}
}

impl FromIterator<char> for ~str {
#[inline]
fn from_iterator<T: Iterator<char>>(iterator: &mut T) -> ~str {
Expand Down