diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6249f7600cd..4b246860006 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -158,6 +158,7 @@ use clone::Clone; use cmp::PartialEq; use default::Default; +use fmt; use kinds::{Copy, Send}; use ops::{Deref, DerefMut, Drop}; use option::Option; @@ -365,6 +366,16 @@ impl<T: PartialEq> PartialEq for RefCell<T> { } } +#[unstable] +impl<T:fmt::Show> fmt::Show for RefCell<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.try_borrow() { + Some(val) => write!(f, "{}", val), + None => write!(f, "<borrowed RefCell>") + } + } +} + struct BorrowRef<'b> { _borrow: &'b Cell<BorrowFlag>, } |
