From 0629ef16e8d93e7e461b025e829b350b5daeed6a Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 24 May 2013 01:16:15 -0400 Subject: [PATCH] use deriving for DeepClone --- src/libstd/cell.rs | 15 +-------------- src/libstd/option.rs | 11 +---------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index b707e3bbb9efa..d1fa9e697bf62 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -21,24 +21,11 @@ Similar to a mutable option type, but friendlier. */ #[mutable] -#[deriving(Clone)] +#[deriving(Clone, DeepClone, Eq)] pub struct Cell { priv value: Option } -impl DeepClone for Cell { - fn deep_clone(&self) -> Cell { - Cell{value: self.value.deep_clone()} - } -} - -impl cmp::Eq for Cell { - fn eq(&self, other: &Cell) -> bool { - (self.value) == (other.value) - } - fn ne(&self, other: &Cell) -> bool { !self.eq(other) } -} - /// Creates a new full cell with the given value. pub fn Cell(value: T) -> Cell { Cell { value: Some(value) } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index bc1ffcdc81ae4..be6ec8c85186c 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -54,21 +54,12 @@ use clone::DeepClone; #[cfg(test)] use str; /// The option type -#[deriving(Clone, Eq)] +#[deriving(Clone, DeepClone, Eq)] pub enum Option { None, Some(T), } -impl DeepClone for Option { - fn deep_clone(&self) -> Option { - match *self { - Some(ref x) => Some(x.deep_clone()), - None => None - } - } -} - impl Ord for Option { fn lt(&self, other: &Option) -> bool { match (self, other) {