diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cell.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 0a3c87f4058..bc28f2f445e 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -55,6 +55,12 @@ impl<T:Pod> Clone for Cell<T> { } } +impl<T:Eq + Pod> Eq for Cell<T> { + fn eq(&self, other: &Cell<T>) -> bool { + self.get() == other.get() + } +} + /// A mutable memory location with dynamically checked borrow rules pub struct RefCell<T> { priv value: T, @@ -273,11 +279,14 @@ mod test { #[test] fn smoketest_cell() { let x = Cell::new(10); + assert_eq!(x, Cell::new(10)); assert_eq!(x.get(), 10); x.set(20); + assert_eq!(x, Cell::new(20)); assert_eq!(x.get(), 20); let y = Cell::new((30, 40)); + assert_eq!(y, Cell::new((30, 40))); assert_eq!(y.get(), (30, 40)); } |
