mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Import Debug implementations for RefCell and friends
This commit is contained in:
parent
c87180a2fb
commit
c50e6add4a
1 changed files with 32 additions and 0 deletions
|
@ -633,3 +633,35 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> {
|
||||||
self.value
|
self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Imported from src/libcore/fmt/mod.rs
|
||||||
|
|
||||||
|
impl<T: ?Sized + Debug> Debug for RefCell<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self.borrow_state() {
|
||||||
|
BorrowState::Unused | BorrowState::Reading => {
|
||||||
|
f.debug_struct("RefCell")
|
||||||
|
.field("value", &self.borrow())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
BorrowState::Writing => {
|
||||||
|
f.debug_struct("RefCell")
|
||||||
|
.field("value", &"<borrowed>")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'b, T: ?Sized + Debug> Debug for Ref<'b, T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
Debug::fmt(&**self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'b, T: ?Sized + Debug> Debug for RefMut<'b, T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
Debug::fmt(&*(self.deref()), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue