about summary refs log tree commit diff
path: root/src/libstd/cell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/cell.rs')
-rw-r--r--src/libstd/cell.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs
index 102b87a3733..eb114e89510 100644
--- a/src/libstd/cell.rs
+++ b/src/libstd/cell.rs
@@ -61,9 +61,9 @@ impl<T:Eq + Copy> Eq for Cell<T> {
     }
 }
 
-impl<T: fmt::Show> fmt::Show for Cell<T> {
+impl<T: Copy + fmt::Show> fmt::Show for Cell<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f.buf, r"Cell \{ value: {} \}", unsafe{*&self.value.get()})
+        write!(f.buf, r"Cell \{ value: {} \}", self.get())
     }
 }
 
@@ -266,6 +266,17 @@ mod test {
     }
 
     #[test]
+    fn cell_has_sensible_show() {
+        use str::StrSlice;
+
+        let x = Cell::new("foo bar");
+        assert!(format!("{}", x).contains(x.get()));
+
+        x.set("baz qux");
+        assert!(format!("{}", x).contains(x.get()));
+    }
+
+    #[test]
     fn double_imm_borrow() {
         let x = RefCell::new(0);
         let _b1 = x.borrow();