auto merge of #8555 : chris-morgan/rust/time-clone, r=huonw
I need `Clone` for `Tm` for my latest work on [rust-http](https://github.com/chris-morgan/rust-http) (static typing for headers, and headers like `Date` are a time), so here it is. @huonw recommended deriving DeepClone while I was at it. I also had to implement `DeepClone` for `~str` to get a derived implementation of `DeepClone` for `Tm`; I did `@str` while I was at it, for consistency.
This commit is contained in:
@@ -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 }
|
||||
|
||||
/*
|
||||
@@ -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]
|
||||
|
||||
@@ -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};
|
||||
@@ -2104,6 +2104,13 @@ 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 {
|
||||
@@ -2111,6 +2118,13 @@ impl Clone for @str {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user