| 1 | use super::*; |
| 2 | |
| 3 | impl<T> Format for core::cell::Cell<T> |
| 4 | where |
| 5 | T: Format + Copy, |
| 6 | { |
| 7 | fn format(&self, fmt: Formatter) { |
| 8 | crate::write!(fmt, "Cell {{ value: {=?} }})" , self.get()) |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | impl<T> Format for core::cell::RefCell<T> |
| 13 | where |
| 14 | T: Format, |
| 15 | { |
| 16 | default_format!(); |
| 17 | |
| 18 | #[inline ] |
| 19 | fn _format_tag() -> Str { |
| 20 | internp!("RefCell {{ value: <borrowed> }}|RefCell {{ value: {=?} }}" ) |
| 21 | } |
| 22 | |
| 23 | #[inline ] |
| 24 | fn _format_data(&self) { |
| 25 | match self.try_borrow() { |
| 26 | Err(_) => export::u8(&0), |
| 27 | Ok(x: Ref<'_, T>) => { |
| 28 | export::u8(&1); |
| 29 | export::istr(&T::_format_tag()); |
| 30 | x._format_data() |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl Format for core::cell::BorrowError { |
| 37 | fn format(&self, fmt: Formatter) { |
| 38 | crate::write!(fmt, "BorrowError" ) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl Format for core::cell::BorrowMutError { |
| 43 | fn format(&self, fmt: Formatter) { |
| 44 | crate::write!(fmt, "BorrowMutError" ) |
| 45 | } |
| 46 | } |
| 47 | |