Trait std::fmt::Debug
[−]
[src]
pub trait Debug { fn fmt(&self, &mut Formatter) -> Result<(), Error>; }
Format trait for the ?
character.
Debug
should format the output in a programmer-facing, debugging context.
Generally speaking, you should just derive
a Debug
implementation.
When used with the alternate format specifier #?
, the output is pretty-printed.
For more information on formatters, see the module-level documentation.
This trait can be used with #[derive]
.
Examples
Deriving an implementation:
fn main() { #[derive(Debug)] struct Point { x: i32, y: i32, } let origin = Point { x: 0, y: 0 }; println!("The origin is: {:?}", origin); }#[derive(Debug)] struct Point { x: i32, y: i32, } let origin = Point { x: 0, y: 0 }; println!("The origin is: {:?}", origin);
Manually implementing:
fn main() { use std::fmt; struct Point { x: i32, y: i32, } impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y) } } let origin = Point { x: 0, y: 0 }; println!("The origin is: {:?}", origin); }use std::fmt; struct Point { x: i32, y: i32, } impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y) } } let origin = Point { x: 0, y: 0 }; println!("The origin is: {:?}", origin);
This outputs:
The origin is: Point { x: 0, y: 0 }
There are a number of debug_*
methods on Formatter
to help you with manual
implementations, such as debug_struct
.
Debug
implementations using either derive
or the debug builder API
on Formatter
support pretty printing using the alternate flag: {:#?}
.
Pretty printing with #?
:
#[derive(Debug)] struct Point { x: i32, y: i32, } let origin = Point { x: 0, y: 0 }; println!("The origin is: {:#?}", origin);
This outputs:
The origin is: Point {
x: 0,
y: 0
}
Required Methods
Implementors
impl<T> Debug for Wrapping<T> where T: Debug
impl Debug for Decoded
impl Debug for FullDecoded
impl<'a> Debug for Part<'a>
impl Debug for Sign
impl Debug for Unpacked
impl Debug for Sign
impl<'a> Debug for Decimal<'a>
impl<'a> Debug for ParseResult<'a>
impl Debug for ParseFloatError
impl Debug for FloatErrorKind
impl Debug for Big32x40
impl Debug for Big8x3
impl Debug for Fp
impl Debug for FpCategory
impl Debug for ParseIntError
impl Debug for IntErrorKind
impl<T> Debug for NonZero<T> where T: Zeroable + Debug
impl<Ret> Debug for fn() -> Ret
impl<Ret> Debug for extern "C" fn() -> Ret
impl<Ret> Debug for unsafe fn() -> Ret
impl<Ret> Debug for unsafe extern "C" fn() -> Ret
impl<Ret, A> Debug for fn(A) -> Ret
impl<Ret, A> Debug for extern "C" fn(A) -> Ret
impl<Ret, A> Debug for unsafe fn(A) -> Ret
impl<Ret, A> Debug for unsafe extern "C" fn(A) -> Ret
impl<Ret, A, B> Debug for fn(A, B) -> Ret
impl<Ret, A, B> Debug for extern "C" fn(A, B) -> Ret
impl<Ret, A, B> Debug for unsafe fn(A, B) -> Ret
impl<Ret, A, B> Debug for unsafe extern "C" fn(A, B) -> Ret
impl<Ret, A, B, C> Debug for fn(A, B, C) -> Ret
impl<Ret, A, B, C> Debug for extern "C" fn(A, B, C) -> Ret
impl<Ret, A, B, C> Debug for unsafe fn(A, B, C) -> Ret
impl<Ret, A, B, C> Debug for unsafe extern "C" fn(A, B, C) -> Ret
impl<Ret, A, B, C, D> Debug for fn(A, B, C, D) -> Ret
impl<Ret, A, B, C, D> Debug for extern "C" fn(A, B, C, D) -> Ret
impl<Ret, A, B, C, D> Debug for unsafe fn(A, B, C, D) -> Ret
impl<Ret, A, B, C, D> Debug for unsafe extern "C" fn(A, B, C, D) -> Ret
impl<Ret, A, B, C, D, E> Debug for fn(A, B, C, D, E) -> Ret
impl<Ret, A, B, C, D, E> Debug for extern "C" fn(A, B, C, D, E) -> Ret
impl<Ret, A, B, C, D, E> Debug for unsafe fn(A, B, C, D, E) -> Ret
impl<Ret, A, B, C, D, E> Debug for unsafe extern "C" fn(A, B, C, D, E) -> Ret
impl<Ret, A, B, C, D, E, F> Debug for fn(A, B, C, D, E, F) -> Ret
impl<Ret, A, B, C, D, E, F> Debug for extern "C" fn(A, B, C, D, E, F) -> Ret
impl<Ret, A, B, C, D, E, F> Debug for unsafe fn(A, B, C, D, E, F) -> Ret
impl<Ret, A, B, C, D, E, F> Debug for unsafe extern "C" fn(A, B, C, D, E, F) -> Ret
impl<Ret, A, B, C, D, E, F, G> Debug for fn(A, B, C, D, E, F, G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Debug for extern "C" fn(A, B, C, D, E, F, G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Debug for unsafe fn(A, B, C, D, E, F, G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Debug for fn(A, B, C, D, E, F, G, H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Debug for extern "C" fn(A, B, C, D, E, F, G, H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Debug for unsafe fn(A, B, C, D, E, F, G, H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G, H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Debug for fn(A, B, C, D, E, F, G, H, I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Debug for extern "C" fn(A, B, C, D, E, F, G, H, I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Debug for unsafe fn(A, B, C, D, E, F, G, H, I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Debug for fn(A, B, C, D, E, F, G, H, I, J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Debug for extern "C" fn(A, B, C, D, E, F, G, H, I, J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Debug for unsafe fn(A, B, C, D, E, F, G, H, I, J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Debug for fn(A, B, C, D, E, F, G, H, I, J, K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Debug for extern "C" fn(A, B, C, D, E, F, G, H, I, J, K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Debug for unsafe fn(A, B, C, D, E, F, G, H, I, J, K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Debug for fn(A, B, C, D, E, F, G, H, I, J, K, L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Debug for extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Debug for unsafe fn(A, B, C, D, E, F, G, H, I, J, K, L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Debug for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, L) -> Ret
impl Debug for RangeFull
impl<Idx> Debug for Range<Idx> where Idx: Debug
impl<Idx> Debug for RangeFrom<Idx> where Idx: Debug
impl<Idx> Debug for RangeTo<Idx> where Idx: Debug
impl Debug for Ordering
impl Debug for Any + 'static
impl Debug for Any + 'static + Send
impl Debug for TypeId
impl<T> Debug for [T; 0] where T: Debug
impl<T> Debug for [T; 1] where T: Debug
impl<T> Debug for [T; 2] where T: Debug
impl<T> Debug for [T; 3] where T: Debug
impl<T> Debug for [T; 4] where T: Debug
impl<T> Debug for [T; 5] where T: Debug
impl<T> Debug for [T; 6] where T: Debug
impl<T> Debug for [T; 7] where T: Debug
impl<T> Debug for [T; 8] where T: Debug
impl<T> Debug for [T; 9] where T: Debug
impl<T> Debug for [T; 10] where T: Debug
impl<T> Debug for [T; 11] where T: Debug
impl<T> Debug for [T; 12] where T: Debug
impl<T> Debug for [T; 13] where T: Debug
impl<T> Debug for [T; 14] where T: Debug
impl<T> Debug for [T; 15] where T: Debug
impl<T> Debug for [T; 16] where T: Debug
impl<T> Debug for [T; 17] where T: Debug
impl<T> Debug for [T; 18] where T: Debug
impl<T> Debug for [T; 19] where T: Debug
impl<T> Debug for [T; 20] where T: Debug
impl<T> Debug for [T; 21] where T: Debug
impl<T> Debug for [T; 22] where T: Debug
impl<T> Debug for [T; 23] where T: Debug
impl<T> Debug for [T; 24] where T: Debug
impl<T> Debug for [T; 25] where T: Debug
impl<T> Debug for [T; 26] where T: Debug
impl<T> Debug for [T; 27] where T: Debug
impl<T> Debug for [T; 28] where T: Debug
impl<T> Debug for [T; 29] where T: Debug
impl<T> Debug for [T; 30] where T: Debug
impl<T> Debug for [T; 31] where T: Debug
impl<T> Debug for [T; 32] where T: Debug
impl Debug for AtomicUsize
impl Debug for AtomicIsize
impl Debug for AtomicBool
impl<T> Debug for AtomicPtr<T>
impl Debug for BorrowState
impl<T> Debug for Option<T> where T: Debug
impl<T, E> Debug for Result<T, E> where E: Debug, T: Debug
impl Debug for i8x16
impl Debug for i16x8
impl Debug for i32x4
impl Debug for i64x2
impl Debug for u8x16
impl Debug for u16x8
impl Debug for u32x4
impl Debug for u64x2
impl Debug for f32x4
impl Debug for f64x2
impl Debug for SearchStep
impl<'a, 'b> Debug for StrSearcher<'a, 'b>
impl Debug for StrSearcherImpl
impl Debug for EmptyNeedle
impl Debug for TwoWaySearcher
impl Debug for ParseBoolError
impl Debug for Utf8Error
impl Debug for RadixFmt<isize, Radix>
impl Debug for isize
impl Debug for RadixFmt<usize, Radix>
impl Debug for usize
impl Debug for RadixFmt<i8, Radix>
impl Debug for i8
impl Debug for RadixFmt<u8, Radix>
impl Debug for u8
impl Debug for RadixFmt<i16, Radix>
impl Debug for i16
impl Debug for RadixFmt<u16, Radix>
impl Debug for u16
impl Debug for RadixFmt<i32, Radix>
impl Debug for i32
impl Debug for RadixFmt<u32, Radix>
impl Debug for u32
impl Debug for RadixFmt<i64, Radix>
impl Debug for i64
impl Debug for RadixFmt<u64, Radix>
impl Debug for u64
impl Debug for Error
impl<'a> Debug for Arguments<'a>
impl<'a, T> Debug for &'a T where T: Debug + ?Sized
impl<'a, T> Debug for &'a mut T where T: Debug + ?Sized
impl Debug for bool
impl Debug for str
impl Debug for char
impl Debug for f32
impl Debug for f64
impl<T> Debug for *const T
impl<T> Debug for *mut T
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Debug for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where T1: Debug, T0: Debug, T6: Debug, T10: Debug, T5: Debug, T11: Debug, T4: Debug, T8: Debug, T9: Debug, T2: Debug, T7: Debug, T3: Debug
impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Debug for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where T4: Debug, T3: Debug, T10: Debug, T7: Debug, T1: Debug, T8: Debug, T11: Debug, T5: Debug, T6: Debug, T9: Debug, T2: Debug
impl<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Debug for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where T2: Debug, T9: Debug, T8: Debug, T5: Debug, T4: Debug, T3: Debug, T10: Debug, T11: Debug, T7: Debug, T6: Debug
impl<T3, T4, T5, T6, T7, T8, T9, T10, T11> Debug for (T3, T4, T5, T6, T7, T8, T9, T10, T11) where T3: Debug, T9: Debug, T5: Debug, T11: Debug, T6: Debug, T4: Debug, T10: Debug, T7: Debug, T8: Debug
impl<T4, T5, T6, T7, T8, T9, T10, T11> Debug for (T4, T5, T6, T7, T8, T9, T10, T11) where T8: Debug, T10: Debug, T7: Debug, T5: Debug, T4: Debug, T6: Debug, T9: Debug, T11: Debug
impl<T5, T6, T7, T8, T9, T10, T11> Debug for (T5, T6, T7, T8, T9, T10, T11) where T10: Debug, T9: Debug, T7: Debug, T6: Debug, T8: Debug, T11: Debug, T5: Debug
impl<T6, T7, T8, T9, T10, T11> Debug for (T6, T7, T8, T9, T10, T11) where T8: Debug, T9: Debug, T6: Debug, T10: Debug, T7: Debug, T11: Debug
impl<T7, T8, T9, T10, T11> Debug for (T7, T8, T9, T10, T11) where T10: Debug, T11: Debug, T8: Debug, T9: Debug, T7: Debug
impl<T8, T9, T10, T11> Debug for (T8, T9, T10, T11) where T11: Debug, T10: Debug, T9: Debug, T8: Debug
impl<T9, T10, T11> Debug for (T9, T10, T11) where T9: Debug, T10: Debug, T11: Debug
impl<T10, T11> Debug for (T10, T11) where T11: Debug, T10: Debug
impl<T11> Debug for (T11,) where T11: Debug
impl<T> Debug for [T] where T: Debug
impl Debug for ()
impl<T> Debug for PhantomData<T>
impl<T> Debug for Cell<T> where T: Copy + Debug
impl<T> Debug for RefCell<T> where T: Debug + ?Sized
impl<'b, T> Debug for Ref<'b, T> where T: Debug + ?Sized
impl<'b, T> Debug for RefMut<'b, T> where T: Debug + ?Sized
impl<T> Debug for Box<T> where T: Debug + ?Sized
impl<T> Debug for Weak<T> where T: Debug + ?Sized
impl<T> Debug for Arc<T> where T: Debug + ?Sized
impl<T> Debug for Rc<T> where T: Debug + ?Sized
impl<T> Debug for Weak<T> where T: Debug + ?Sized
impl<T> Debug for BinaryHeap<T> where T: Ord + Debug
impl<K, V> Debug for BTreeMap<K, V> where V: Debug, K: Debug
impl<T> Debug for BTreeSet<T> where T: Debug
impl<'a, B> Debug for Cow<'a, B> where B: Debug + ToOwned + ?Sized, B::Owned: Debug
impl<E> Debug for EnumSet<E> where E: CLike + Debug
impl<A> Debug for LinkedList<A> where A: Debug
impl Debug for FromUtf8Error
impl Debug for FromUtf16Error
impl Debug for String
impl Debug for ParseError
impl<T> Debug for Vec<T> where T: Debug
impl<T> Debug for VecDeque<T> where T: Debug
impl<T> Debug for Bound<T> where T: Debug
impl Debug for Utf16Item
impl Debug for Thread
impl<K, V, S> Debug for HashMap<K, V, S> where K: Eq + Hash + Debug, V: Debug, S: HashState
impl<T, S> Debug for HashSet<T, S> where T: Eq + Hash + Debug, S: HashState
impl Debug for VarError
impl Debug for JoinPathsError
impl Debug for NulError
impl Debug for IntoStringError
impl Debug for CString
impl Debug for CStr
impl Debug for OsString
impl Debug for OsStr
impl Debug for Permissions
impl Debug for File
impl<R> Debug for BufReader<R> where R: Debug
impl<W: Debug> Debug for IntoInnerError<W>
impl<W: Write> Debug for BufWriter<W> where W: Debug
impl<W: Write> Debug for LineWriter<W> where W: Debug
impl<T: Debug> Debug for Cursor<T>
impl Debug for Error
impl Debug for ErrorKind
impl Debug for SeekFrom
impl Debug for CharsError
impl Debug for IpAddr
impl Debug for Ipv6MulticastScope
impl Debug for Ipv4Addr
impl Debug for Ipv6Addr
impl Debug for SocketAddr
impl Debug for SocketAddrV4
impl Debug for SocketAddrV6
impl Debug for TcpStream
impl Debug for TcpListener
impl Debug for UdpSocket
impl Debug for AddrParseError
impl Debug for Shutdown
impl<'a> Debug for Prefix<'a>
impl<'a> Debug for PrefixComponent<'a>
impl<'a> Debug for Component<'a>
impl Debug for PathBuf
impl Debug for Path
impl<'a> Debug for Display<'a>
impl Debug for Command
impl Debug for ExitStatus
impl Debug for RecvError
impl Debug for TryRecvError
impl<T> Debug for SendError<T>
impl<T> Debug for TrySendError<T>
impl Debug for WaitTimeoutResult
impl<T: ?Sized + Debug + 'static> Debug for Mutex<T>
impl<T: ?Sized + Debug> Debug for RwLock<T>
impl Debug for Duration
impl Debug for SystemTimeError
impl Debug for Instant
impl Debug for SystemTime
impl<T> Debug for PoisonError<T>
impl<T> Debug for TryLockError<T>