Skip to content

Commit 0629ef1

Browse files
committed
use deriving for DeepClone
1 parent a776d65 commit 0629ef1

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

src/libstd/cell.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,11 @@ Similar to a mutable option type, but friendlier.
2121
*/
2222

2323
#[mutable]
24-
#[deriving(Clone)]
24+
#[deriving(Clone, DeepClone, Eq)]
2525
pub struct Cell<T> {
2626
priv value: Option<T>
2727
}
2828

29-
impl<T: DeepClone> DeepClone for Cell<T> {
30-
fn deep_clone(&self) -> Cell<T> {
31-
Cell{value: self.value.deep_clone()}
32-
}
33-
}
34-
35-
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
36-
fn eq(&self, other: &Cell<T>) -> bool {
37-
(self.value) == (other.value)
38-
}
39-
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
40-
}
41-
4229
/// Creates a new full cell with the given value.
4330
pub fn Cell<T>(value: T) -> Cell<T> {
4431
Cell { value: Some(value) }

src/libstd/option.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,12 @@ use clone::DeepClone;
5454
#[cfg(test)] use str;
5555

5656
/// The option type
57-
#[deriving(Clone, Eq)]
57+
#[deriving(Clone, DeepClone, Eq)]
5858
pub enum Option<T> {
5959
None,
6060
Some(T),
6161
}
6262

63-
impl<T: DeepClone> DeepClone for Option<T> {
64-
fn deep_clone(&self) -> Option<T> {
65-
match *self {
66-
Some(ref x) => Some(x.deep_clone()),
67-
None => None
68-
}
69-
}
70-
}
71-
7263
impl<T:Ord> Ord for Option<T> {
7364
fn lt(&self, other: &Option<T>) -> bool {
7465
match (self, other) {

0 commit comments

Comments
 (0)