about summary refs log tree commit diff
path: root/src/libcore/cell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/cell.rs')
-rw-r--r--src/libcore/cell.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index da247c648fc..cfd1b8dfef0 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use cast::transmute;
 use option;
 use prelude::*;
 
@@ -15,11 +16,21 @@ use prelude::*;
 ///
 /// Similar to a mutable option type, but friendlier.
 
-#[deriving_eq]
 pub struct Cell<T> {
     mut value: Option<T>
 }
 
+impl<T:cmp::Eq> cmp::Eq for Cell<T> {
+    pure fn eq(&self, other: &Cell<T>) -> bool {
+        unsafe {
+            let frozen_self: &Option<T> = transmute(&mut self.value);
+            let frozen_other: &Option<T> = transmute(&mut other.value);
+            frozen_self == frozen_other
+        }
+    }
+    pure 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) }