From 8846970bba8d529f4361eec65d39254060483e03 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 24 Feb 2014 21:38:40 -0400 Subject: [PATCH] Implement Eq for Cell --- src/libstd/cell.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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 @@ fn clone(&self) -> Cell { } } +impl Eq for Cell { + fn eq(&self, other: &Cell) -> bool { + self.get() == other.get() + } +} + /// A mutable memory location with dynamically checked borrow rules pub struct RefCell { 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)); } -- GitLab