Trait Debug
trait Debug: PointeeSized
? formatting.
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] if all fields implement Debug. When
derived for structs, it will use the name of the struct, then {, then a
comma-separated list of each field's name and Debug value, then }. For
enums, it will use the name of the variant and, if applicable, (, then the
Debug values of the fields, then ).
Stability
Derived Debug formats are not stable, and so may change with future Rust
versions. Additionally, Debug implementations of types provided by the
standard library (std, core, alloc, etc.) are not stable, and
may also change with future Rust versions.
Examples
Deriving an implementation:
let origin = Point ;
assert_eq!;
Manually implementing:
use fmt;
let origin = Point ;
assert_eq!;
There are a number of helper methods on the Formatter struct to help you with manual
implementations, such as debug_struct.
Types that do not wish to use the standard suite of debug representations
provided by the Formatter trait (debug_struct, debug_tuple,
debug_list, debug_set, debug_map) can do something totally custom by
manually writing an arbitrary representation to the Formatter.
# use fmt;
#
#
Debug implementations using either derive or the debug builder API
on Formatter support pretty-printing using the alternate flag: {:#?}.
Pretty-printing with #?:
let origin = Point ;
let expected = "The origin is: Point {
x: 0,
y: 0,
}";
assert_eq!;
Required Methods
fn fmt(self: &Self, f: &mut Formatter<'_>) -> ResultFormats the value using the given formatter.
Errors
This function should return
Errif, and only if, the providedFormatterreturnsErr. String formatting is considered an infallible operation; this function only returns aResultbecause writing to the underlying stream might fail and it must provide a way to propagate the fact that an error has occurred back up the stack.Examples
use fmt; let position = Position ; assert_eq!; assert_eq!;
Implementors
impl Debug for int8x8x4_timpl<I: $crate::fmt::Debug> Debug for Copied<I>impl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksExactMut<'a, T>impl<Idx: fmt::Debug> Debug for RangeFrom<Idx>impl Debug for float32x2x3_timpl Debug for Wakerimpl Debug for u64impl Debug for vector_unsigned_shortimpl Debug for int16x8x3_timpl<'a, P> Debug for MatchIndices<'a, P>impl Debug for poly64x2x2_timpl Debug for objc_selectorimpl<F> Debug for FromFn<F>impl Debug for int16x8_timpl<T: $crate::fmt::Debug> Debug for Yeet<T>impl<'a> Debug for PanicInfo<'a>impl<I: $crate::fmt::Debug> Debug for FromIter<I>impl<A: $crate::fmt::Debug> Debug for RangeFromIter<A>impl<T: fmt::Debug, P> Debug for SplitInclusive<'_, T, P>impl Debug for vector_signed_shortimpl Debug for uint32x2x2_timpl<'a, 'b> Debug for StrSearcher<'a, 'b>impl Debug for objc_classimpl Debug for f32impl Debug for float64x1_timpl Debug for uint8x16x2_timpl<'a, T: 'a + fmt::Debug, P> Debug for ChunkByMut<'a, T, P>impl<T: ?Sized> Debug for crate::marker::PhantomData<T>impl Debug for int64x1x4_timpl Debug for poly8x8_timpl Debug for strimpl Debug for vector_unsigned_longimpl Debug for uint16x8x4_timpl<'a> Debug for SplitAsciiWhitespace<'a>impl<I> Debug for DecodeUtf16<I>impl Debug for __m256impl<I: fmt::Debug, U, F> Debug for FlatMap<I, U, F>impl Debug for uint64x2_timpl<I: fmt::Debug, P> Debug for TakeWhile<I, P>impl<T: fmt::Debug, P> Debug for SplitNMut<'_, T, P>impl Debug for vector_unsigned_long_longimpl Debug for float16x4x3_timpl<T: $crate::fmt::Debug> Debug for Ready<T>impl Debug for i64impl Debug for float64x2x4_timpl Debug for SocketAddrV6impl Debug for poly8x16x3_timpl Debug for PhantomCovariantLifetime<'_>impl<'a, P> Debug for Split<'a, P>impl<T: $crate::fmt::Debug> Debug for Bound<T>impl Debug for uint64x2x2_timpl Debug for int64x1_timpl Debug for VaList<'_>impl Debug for SipHasherimpl Debug for m128iimpl Debug for int32x2x2_timpl Debug for SearchStepimpl Debug for __m512bhimpl Debug for AtomicU8impl Debug for int8x16x2_timpl<'a, T: $crate::fmt::Debug + 'a, N: usize> Debug for ArrayWindows<'a, T, N>impl Debug for ToUppercaseimpl Debug for AtomicI32impl Debug for Arrayimpl Debug for float32x2x4_timpl Debug for LocalWakerimpl Debug for AtomicU64impl Debug for u128impl Debug for vector_bool_shortimpl<T: ?Sized + Debug> Debug for crate::cell::Ref<'_, T>impl Debug for int16x8x4_timpl<'a, P> Debug for RMatchIndices<'a, P>impl<T: ?Sized> Debug for UnsafePinned<T>impl Debug for AtomicOrderingimpl<I, G> Debug for IntersperseWith<I, G>impl Debug for IntErrorKindimpl Debug for poly64x2x3_timpl Debug for Assumeimpl Debug for uint16x8_timpl<T: fmt::Debug, P> Debug for SplitMut<'_, T, P>impl Debug for vector_unsigned_shortimpl Debug for uint32x2x3_timpl<'a> Debug for Utf8Chunk<'a>impl Debug for f64impl Debug for float64x2_timpl Debug for BorrowMutErrorimpl Debug for uint8x16x3_timpl Debug for GetDisjointMutErrorimpl Debug for int64x2x2_timpl Debug for int16x4_timpl<T: $crate::fmt::Debug> Debug for Reverse<T>impl Debug for BorrowErrorimpl Debug for charimpl Debug for vector_bool_longimpl Debug for poly16x4x2_timpl<'a, P: Pattern<Searcher<'a>: fmt::Debug>> Debug for SplitInclusive<'a, P>impl Debug for __m256dimpl<'a> Debug for Bytes<'a>impl Debug for poly64x2_timpl<T: $crate::fmt::Debug> Debug for IntoIter<T>impl<T: fmt::Debug, P> Debug for RSplitNMut<'_, T, P>impl Debug for vector_bool_long_longimpl Debug for float16x4x4_timpl<T> Debug for PhantomCovariant<T>impl<T: $crate::fmt::Debug> Debug for Poll<T>impl<I: fmt::Debug, P> Debug for MapWhile<I, P>impl Debug for i128impl Debug for v128impl<I: $crate::fmt::Debug + Iterator> Debug for Peekable<I>impl Debug for poly8x16x4_timpl<'a, P> Debug for RSplit<'a, P>impl Debug for TypeIdimpl Debug for uint64x2x3_timpl Debug for SocketAddrimpl<I: $crate::fmt::Debug> Debug for StepBy<I>impl Debug for uint64x1_timpl<H> Debug for BuildHasherDefault<H>impl Debug for m128impl<T: $crate::fmt::Debug + ?Sized> Debug for ManuallyDrop<T>impl Debug for int32x2x3_timpl<I: $crate::fmt::Debug + Iterator> Debug for Intersperse<I>impl<'a> Debug for CharSearcher<'a>impl<F: FnPtr> Debug for Fimpl Debug for __m128himpl Debug for int8x16x3_timpl Debug for TypeKindimpl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunks<'a, T>impl Debug for float32x4x2_timpl Debug for Layoutimpl Debug for usizeimpl Debug for vector_signed_intimpl Debug for Lastimpl Debug for uint16x4x2_timpl<'a, P> Debug for Matches<'a, P>impl<I: $crate::fmt::Debug + Iterator, N: usize> Debug for ArrayChunks<I, N>impl Debug for poly64x2x4_timpl Debug for poly16x8_timpl<'a, T: $crate::fmt::Debug + 'a> Debug for IterMut<'a, T>impl<T: fmt::Debug, P> Debug for SplitInclusiveMut<'_, T, P>impl Debug for vector_bool_shortimpl Debug for uint32x2x4_timpl<Idx: fmt::Debug> Debug for RangeFrom<Idx>impl<'a> Debug for Source<'a>impl Debug for Utf8Chunks<'_>impl Debug for f16impl Debug for float64x1x2_timpl Debug for uint8x16x4_timpl Debug for Utf8Errorimpl<F> Debug for FromFn<F>impl Debug for int64x2x3_timpl Debug for uint16x4_timpl Debug for Location<'_>impl<T: PointeeSized> Debug for *const Timpl Debug for vector_doubleimpl Debug for Errorimpl Debug for poly16x4x3_timpl Debug for EncodeUtf16<'_>impl<I: fmt::Debug, P> Debug for SkipWhile<I, P>impl Debug for __m512iimpl<T: ?Sized + Debug> Debug for crate::cell::RefCell<T>impl Debug for float16x4_timpl<'a, T: $crate::fmt::Debug + 'a> Debug for Windows<'a, T>impl Debug for vector_floatimpl Debug for DebugAsHeximpl Debug for float16x8x2_timpl Debug for RawWakerimpl Debug for TryFromSliceErrorimpl Debug for isizeimpl<F> Debug for RepeatWith<F>impl Debug for vector_signed_charimpl Debug for int16x4x2_timpl<'a, P> Debug for SplitTerminator<'a, P>impl Debug for uint64x2x4_timpl Debug for AtomicI8impl Debug for Alignmentimpl Debug for poly64x1_timpl<'a> Debug for EscapeAscii<'a>impl Debug for m128dimpl Debug for int32x2x4_timpl<'a, N: usize> Debug for CharArraySearcher<'a, N>impl Debug for AtomicI64impl Debug for dyn Anyimpl Debug for __m256himpl<T: $crate::fmt::Debug, E: $crate::fmt::Debug> Debug for Result<T, E>impl<I: Iterator + fmt::Debug, F, N: usize> Debug for MapWindows<I, F, N>impl Debug for int8x16x4_timpl Debug for AtomicUsizeimpl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksMut<'a, T>impl<T: fmt::Debug, F> Debug for LazyCell<T, F>impl<T: ?Sized> Debug for crate::cell::SyncUnsafeCell<T>impl Debug for float32x4x3_timpl<Idx: fmt::Debug> Debug for RangeTo<Idx>impl<Idx: $crate::fmt::Debug> Debug for Clamp<Idx>impl Debug for LayoutErrorimpl Debug for SocketAddrV4impl<T: PointeeSized + Debug> Debug for &Timpl Debug for vector_unsigned_intimpl Debug for PanicMessage<'_>impl Debug for Localityimpl Debug for uint16x4x3_timpl<'a, P> Debug for RMatches<'a, P>impl Debug for Orderingimpl<T> Debug for Discriminant<T>impl Debug for __m128iimpl Debug for Orderingimpl Debug for int32x4_timpl<T: fmt::Debug, P> Debug for RSplit<'_, T, P>impl Debug for vector_signed_intimpl Debug for Signimpl Debug for uint32x4x2_timpl<T: fmt::Debug> Debug for OnceCell<T>impl Debug for Durationimpl Debug for EscapeDefaultimpl<Ptr: fmt::Debug> Debug for Pin<Ptr>impl Debug for f128impl Debug for float64x1x3_timpl<'a, T: $crate::fmt::Debug + 'a> Debug for Iter<'a, T>impl<I, U> Debug for Flatten<I>impl<T: $crate::fmt::Debug + NumBufferTrait> Debug for NumBuffer<T>impl Debug for poly8x8x2_timpl Debug for ParseBoolErrorimpl Debug for ParseCharErrorimpl<T: PointeeSized> Debug for NonNull<T>impl<I: $crate::fmt::Debug> Debug for Skip<I>impl Debug for int64x2x4_timpl<'a, I: $crate::fmt::Debug> Debug for ByRefSized<'a, I>impl Debug for poly16x4_timpl<T: PointeeSized> Debug for *mut Timpl Debug for f16x2impl Debug for poly16x4x4_timpl<'a> Debug for EscapeDebug<'a>impl Debug for __m512impl Debug for float16x8_timpl Debug for Infallibleimpl<'a, T: $crate::fmt::Debug + 'a> Debug for Chunks<'a, T>impl Debug for vector_doubleimpl Debug for AtomicBoolimpl Debug for float16x8x3_timpl Debug for RawWakerVTableimpl Debug for u8impl Debug for vector_unsigned_charimpl Debug for Typeimpl Debug for int16x4x3_timpl<'a, P> Debug for RSplitTerminator<'a, P>impl Debug for TryFromCharErrorimpl<T> Debug for AtomicPtr<T>impl Debug for poly64x1x2_timpl Debug for int8x16_timpl<T: fmt::Debug> Debug for Iter<'_, T>impl Debug for vector_signed_charimpl Debug for ToLowercaseimpl Debug for AtomicU16impl Debug for Tupleimpl Debug for int32x4x2_timpl<'a, 'b, N: usize> Debug for CharArrayRefSearcher<'a, 'b, N>impl<T: Copy + Debug> Debug for crate::cell::Cell<T>impl Debug for DecodeUtf16Errorimpl Debug for dyn Any + Sendimpl Debug for __m512himpl Debug for uint8x8x2_timpl<T: fmt::Debug, F> Debug for Successors<T, F>impl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksExact<'a, T>impl Debug for float32x4x4_timpl Debug for AllocErrorimpl Debug for EscapeUnicodeimpl<I: $crate::fmt::Debug> Debug for Take<I>impl<T: PointeeSized + Debug> Debug for &mut Timpl Debug for vector_bool_intimpl Debug for uint16x4x4_timpl<Idx: fmt::Debug> Debug for RangeInclusive<Idx>impl<'a> Debug for Lines<'a>impl Debug for AsciiCharimpl Debug for __m128impl<B: $crate::fmt::Debug, C: $crate::fmt::Debug> Debug for ControlFlow<B, C>impl Debug for uint32x4_timpl<T: fmt::Debug, P> Debug for RSplitMut<'_, T, P>impl Debug for vector_unsigned_intimpl<T: fmt::Debug> Debug for Saturating<T>impl Debug for uint32x4x3_timpl Debug for Ipv6MulticastScopeimpl Debug for CharTryFromErrorimpl Debug for TryFromFloatSecsErrorimpl Debug for i8impl Debug for float64x1x4_timpl Debug for EscapeDefaultimpl<I: $crate::fmt::Debug> Debug for Cloned<I>impl<T> Debug for Empty<T>impl Debug for poly8x8x3_timpl<Idx: fmt::Debug> Debug for RangeToInclusive<Idx>impl Debug for Chars<'_>impl<'a> Debug for BorrowedCursor<'a>impl Debug for uint64x1x2_timpl Debug for int32x2_timpl<Dyn: PointeeSized> Debug for DynMetadata<Dyn>impl<T: Debug> Debug for (T)impl Debug for m256iimpl Debug for poly16x8x2_timpl<T: $crate::fmt::Debug> Debug for Option<T>impl<'a> Debug for EscapeDefault<'a>impl<F> Debug for OnceWith<F>impl Debug for CStrimpl<Idx: fmt::Debug> Debug for RangeToInclusive<Idx>impl Debug for __m512dimpl Debug for int8x8x2_timpl Debug for EscapeDebugimpl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksMut<'a, T>impl<T, N: usize> Debug for crate::simd::Simd<T, N>impl Debug for float16x8x4_timpl Debug for AddrParseErrorimpl<I: fmt::Debug, P> Debug for Filter<I, P>impl Debug for Context<'_>impl Debug for u16impl Debug for vector_bool_charimpl Debug for int16x4x4_timpl<'a, P> Debug for SplitN<'a, P>impl<T: $crate::fmt::Debug> Debug for Once<T>impl Debug for AtomicU32impl Debug for poly64x1x3_timpl<T> Debug for PhantomInvariant<T>impl Debug for uint8x16_timpl<Idx: fmt::Debug> Debug for Range<Idx>impl Debug for AtomicIsizeimpl<T: fmt::Debug> Debug for IterMut<'_, T>impl Debug for vector_unsigned_charimpl Debug for Ipv4Addrimpl Debug for int32x4x3_timpl Debug for PhantomInvariantLifetime<'_>impl<'a, 'b> Debug for CharSliceSearcher<'a, 'b>impl Debug for dyn Any + Send + Syncimpl Debug for bf16impl<F> Debug for fn(_: T) -> Retimpl Debug for uint8x8x3_timpl<Idx: fmt::Debug> Debug for Range<Idx>impl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksExactMut<'a, T>impl<'a> Debug for Request<'a>impl Debug for int64x1x2_timpl Debug for RangeFullimpl Debug for int8x8_timpl Debug for neverimpl Debug for vector_floatimpl Debug for uint16x8x2_timpl<I: fmt::Debug, St: fmt::Debug, F> Debug for Scan<I, St, F>impl<'a> Debug for LinesAny<'a>impl<P: $crate::fmt::Debug + ?Sized> Debug for MaybeDangling<P>impl Debug for __m128dimpl Debug for float32x4_timpl<T: fmt::Debug, P> Debug for SplitN<'_, T, P>impl Debug for vector_bool_intimpl Debug for ByteStrimpl<I: fmt::Debug, F> Debug for Inspect<I, F>impl Debug for uint32x4x4_timpl<T> Debug for Pending<T>impl<A: $crate::fmt::Debug> Debug for Repeat<A>impl Debug for i16impl Debug for float64x2x2_timpl Debug for poly8x8x4_timpl Debug for TryFromIntErrorimpl<'a> Debug for CharIndices<'a>impl Debug for FormattingOptionsimpl Debug for uint64x1x3_timpl Debug for FromBytesWithNulErrorimpl Debug for uint32x2_timpl<T: Debug> Debug for [T]impl Debug for m256impl<T: $crate::fmt::Debug> Debug for Rev<T>impl Debug for poly16x8x3_timpl Debug for Ipv6Addrimpl<'a> Debug for EscapeUnicode<'a>impl<I: fmt::Debug, F> Debug for Map<I, F>impl Debug for __m128bhimpl<A: $crate::fmt::Debug> Debug for RangeIter<A>impl Debug for int8x8x3_timpl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksExact<'a, T>impl<T, N: usize> Debug for Mask<T, N>impl Debug for BorrowedBuf<'_>impl Debug for float32x2x2_timpl<'a> Debug for ContextBuilder<'a>impl Debug for u32impl Debug for vector_signed_shortimpl Debug for IpAddrimpl Debug for AtomicI16impl Debug for int16x8x2_timpl<T: ?Sized> Debug for crate::cell::UnsafeCell<T>impl<I: $crate::fmt::Debug> Debug for Cycle<I>impl Debug for Fieldimpl<T: ?Sized> Debug for Exclusive<T>impl<'a, P> Debug for RSplitN<'a, P>impl<'a, A: $crate::fmt::Debug + 'a> Debug for IterMut<'a, A>impl Debug for poly64x1x4_timpl Debug for poly8x16_timpl<T: fmt::Debug, P> Debug for Split<'_, T, P>impl Debug for vector_bool_charimpl Debug for SimdAlignimpl Debug for c_voidimpl Debug for int32x4x4_timpl<'a, A: $crate::fmt::Debug + 'a> Debug for Iter<'a, A>impl<T> Debug for MaybeUninit<T>impl<F> Debug for CharPredicateSearcher<'_, F>impl<T: fmt::Debug, N: usize> Debug for IntoIter<T, N>impl<T: fmt::Debug, N: usize> Debug for [T; N]impl Debug for CpuidResultimpl<Y: $crate::fmt::Debug, R: $crate::fmt::Debug> Debug for CoroutineState<Y, R>impl Debug for FpCategoryimpl<A: $crate::fmt::Debug> Debug for RangeInclusiveIter<A>impl Debug for uint8x8x4_timpl<'a, T: 'a + fmt::Debug, P> Debug for ChunkBy<'a, T, P>impl<I: $crate::fmt::Debug> Debug for Enumerate<I>impl Debug for ParseIntErrorimpl Debug for int64x1x3_timpl Debug for uint8x8_timpl<T: fmt::Debug> Debug for Wrapping<T>impl Debug for boolimpl Debug for vector_signed_longimpl<I: $crate::fmt::Debug> Debug for Fuse<I>impl<G> Debug for FromCoroutine<G>impl Debug for uint16x8x3_timpl Debug for PhantomContravariantLifetime<'_>impl<'a> Debug for SplitWhitespace<'a>impl<A: $crate::fmt::Debug> Debug for IntoIter<A>impl Debug for __m256iimpl<A: $crate::fmt::Debug, B: $crate::fmt::Debug> Debug for Chain<A, B>impl Debug for int64x2_timpl Debug for Alignmentimpl<T: fmt::Debug, P> Debug for RSplitN<'_, T, P>impl Debug for vector_signed_long_longimpl<T> Debug for NonZero<T>impl Debug for float16x4x2_timpl<F> Debug for PollFn<F>impl Debug for FromBytesUntilNulErrorimpl Debug for i32impl Debug for float64x2x3_timpl<T: fmt::Debug> Debug for AssertUnwindSafe<T>impl Debug for poly8x16x2_timpl Debug for PhantomPinnedimpl<A: Debug, B: Debug> Debug for Zip<A, B>impl<'a> Debug for Bytes<'a>impl Debug for uint64x1x4_timpl<I: fmt::Debug, F> Debug for FilterMap<I, F>impl Debug for float32x2_timpl<T, F> Debug for DropGuard<T, F>impl Debug for ()impl Debug for m256dimpl<T: ?Sized + Debug> Debug for crate::cell::RefMut<'_, T>impl Debug for poly16x8x4_timpl<'a> Debug for Utf8Pattern<'a>impl<A: $crate::fmt::Debug> Debug for OptionFlatten<A>impl<T> Debug for PhantomContravariant<T>impl Debug for Arguments<'_>impl<A: fmt::Debug> Debug for RepeatN<A>impl Debug for __m256bhimpl<Idx: fmt::Debug> Debug for RangeInclusive<Idx>