Skip to content

Commit 0a23828

Browse files
committed
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.
2 parents 3bc6858 + 1f41140 commit 0a23828

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/libextra/time.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub mod rustrt {
3434
}
3535

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

4040
/*
@@ -100,7 +100,7 @@ pub fn tzset() {
100100
}
101101
}
102102

103-
#[deriving(Eq, Encodable, Decodable)]
103+
#[deriving(Clone, DeepClone, Eq, Encodable, Decodable)]
104104
pub struct Tm {
105105
tm_sec: i32, // seconds after the minute ~[0-60]
106106
tm_min: i32, // minutes after the hour ~[0-59]

src/libstd/str.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use at_vec;
2020
use cast;
2121
use char;
2222
use char::Char;
23-
use clone::Clone;
23+
use clone::{Clone, DeepClone};
2424
use container::{Container, Mutable};
2525
use iter::Times;
2626
use iterator::{Iterator, FromIterator, Extendable};
@@ -2104,13 +2104,27 @@ impl Clone for ~str {
21042104
}
21052105
}
21062106
2107+
impl DeepClone for ~str {
2108+
#[inline]
2109+
fn deep_clone(&self) -> ~str {
2110+
self.to_owned()
2111+
}
2112+
}
2113+
21072114
impl Clone for @str {
21082115
#[inline]
21092116
fn clone(&self) -> @str {
21102117
*self
21112118
}
21122119
}
21132120
2121+
impl DeepClone for @str {
2122+
#[inline]
2123+
fn deep_clone(&self) -> @str {
2124+
*self
2125+
}
2126+
}
2127+
21142128
impl FromIterator<char> for ~str {
21152129
#[inline]
21162130
fn from_iterator<T: Iterator<char>>(iterator: &mut T) -> ~str {

0 commit comments

Comments
 (0)