1
Fork 0

use deriving for DeepClone

This commit is contained in:
Daniel Micay 2013-05-24 01:16:15 -04:00
parent a776d65b4d
commit 0629ef16e8
2 changed files with 2 additions and 24 deletions

View file

@ -21,24 +21,11 @@ Similar to a mutable option type, but friendlier.
*/
#[mutable]
#[deriving(Clone)]
#[deriving(Clone, DeepClone, Eq)]
pub struct Cell<T> {
priv value: Option<T>
}
impl<T: DeepClone> DeepClone for Cell<T> {
fn deep_clone(&self) -> Cell<T> {
Cell{value: self.value.deep_clone()}
}
}
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
fn eq(&self, other: &Cell<T>) -> bool {
(self.value) == (other.value)
}
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
}
/// Creates a new full cell with the given value.
pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(value) }