#[derive(Clone)]
pub(crate) struct DebugWrapper<T>(&'static str, T);
impl<T> std::fmt::Debug for DebugWrapper<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl<T> std::ops::Deref for DebugWrapper<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.1
}
}
impl<T> std::ops::DerefMut for DebugWrapper<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.1
}
}
impl<T> DebugWrapper<T> {
pub(crate) fn wrap(obj: T, name: &'static str) -> Self {
Self(name, obj)
}
}