@@ -5,7 +5,7 @@ use core::ptr::NonNull;
55use std:: {
66 cell:: UnsafeCell ,
77 error:: Error ,
8- fmt:: { Display , Error as FormatError , Formatter } ,
8+ fmt:: { Debug , Display , Error as FormatError , Formatter } ,
99 ops:: { Deref , DerefMut } ,
1010 sync:: atomic:: { AtomicUsize , Ordering } ,
1111 usize,
@@ -41,7 +41,6 @@ impl Error for InvalidBorrow {
4141/// An immutable reference to data in a `TrustCell`.
4242///
4343/// Access the value via `std::ops::Deref` (e.g. `*val`)
44- #[ derive( Debug ) ]
4544pub struct Ref < ' a , T : ?Sized + ' a > {
4645 flag : & ' a AtomicUsize ,
4746 value : NonNull < T > ,
@@ -135,10 +134,15 @@ impl<'a, T: ?Sized> Clone for Ref<'a, T> {
135134 }
136135}
137136
137+ impl < ' a , T : ?Sized + Debug > Debug for Ref < ' a , T > {
138+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , FormatError > {
139+ <T as Debug >:: fmt ( self , f)
140+ }
141+ }
142+
138143/// A mutable reference to data in a `TrustCell`.
139144///
140145/// Access the value via `std::ops::DerefMut` (e.g. `*val`)
141- #[ derive( Debug ) ]
142146pub struct RefMut < ' a , T : ?Sized + ' a > {
143147 flag : & ' a AtomicUsize ,
144148 value : NonNull < T > ,
@@ -245,6 +249,12 @@ impl<'a, T: ?Sized> Drop for RefMut<'a, T> {
245249 }
246250}
247251
252+ impl < ' a , T : ?Sized + Debug > Debug for RefMut < ' a , T > {
253+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , FormatError > {
254+ <T as Debug >:: fmt ( self , f)
255+ }
256+ }
257+
248258/// A custom cell container that is a `RefCell` with thread-safety.
249259#[ derive( Debug ) ]
250260pub struct TrustCell < T > {
0 commit comments