Open
Description
For Atomic
, Owned
and Shared
would there be interest in a more complete Debug
implementation? I had a few ideas for going about this without getting in the way
#[cfg(feature = "debug"]
would enable a whole differentimpl<T: Debug> Debug for _
- a method
Atomic::debug(&self) -> &dyn Debug
- using autoref-specialization this would be the main
impl<T: Debug> Debug for Owned
andimpl<T> Debug for &Owned
would be the autoref fall back.
either way the general idea would be
let g = epoch::pin();
let data = self.data.load(Ordering::???);
let (raw, tag) = decompose_data::<T>(data);
let shared = self.load(Ordering::SeqCst, &g);
// this would be how all are "safely" printed unless I'm missing something
let inner = if shared.is_null() {
&"null" as &dyn fmt::Debug
} else {
unsafe { shared.deref() as &dyn fmt::Debug }
};
// if Debug
f.debug_struct("Atomic")
.field("raw", &raw)
.field("inner", inner)
.field("tag", &tag)
.finish()
If interested I can start a PR!