1#![feature(core_intrinsics)]
2
3use std::fmt::{Debug, Formatter, Result};
4use std::intrinsics::type_name;
5use std::ops::{Deref, DerefMut};
6
7#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct WrapDebug<T>(pub T);
9
10impl<T> WrapDebug<T> {
11 pub fn into_inner(self) -> T {
12 self.0
13 }
14}
15
16impl<T> Deref for WrapDebug<T> {
17 type Target = T;
18 fn deref(&self) -> &T {
19 &self.0
20 }
21}
22
23impl<T> DerefMut for WrapDebug<T> {
24 fn deref_mut(&mut self) -> &mut T {
25 &mut self.0
26 }
27}
28
29impl<T> Debug for WrapDebug<T> {
30 fn fmt(&self, fmt: &mut Formatter) -> Result {
31 fmt.write_str(unsafe { type_name::<T>() })
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use WrapDebug;
38 #[test]
39 fn test() {
40 let value: String = "asdf".into();
41 assert_eq!(format!("{:?}", WrapDebug(value)), "std::string::String");
42 }
43}