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 Genericimpl<I: $crate::fmt::Debug> Debug for StepBy<I>impl<T> Debug for AtomicPtr<T>impl<'a> Debug for SplitWhitespace<'a>impl Debug for poly8x16x2_timpl Debug for __m256bhimpl<A: $crate::fmt::Debug, B: $crate::fmt::Debug> Debug for Chain<A, B>impl Debug for f16impl Debug for EncodeUtf16<'_>impl Debug for int16x4x2_timpl Debug for __m256himpl<T: $crate::fmt::Debug> Debug for Yeet<T>impl Debug for i16impl<'a> Debug for EscapeUnicode<'a>impl Debug for int16x8x2_timpl Debug for SocketAddrimpl<P: $crate::fmt::Debug + ?Sized> Debug for MaybeDangling<P>impl Debug for CpuidResultimpl<I: $crate::fmt::Debug + Iterator, N: usize> Debug for ArrayChunks<I, N>impl Debug for i128impl<'a> Debug for CharSearcher<'a>impl Debug for ToLowercaseimpl Debug for uint16x4x2_timpl Debug for float64x1x2_timpl<T: $crate::fmt::Debug> Debug for Option<T>impl Debug for Signimpl Debug for u16impl<'a, 'b> Debug for CharSliceSearcher<'a, 'b>impl<A: $crate::fmt::Debug> Debug for RangeInclusiveIter<A>impl Debug for uint16x8x2_timpl Debug for float64x2x2_timpl Debug for Lastimpl Debug for ByteStrimpl<I> Debug for DecodeUtf16<I>impl Debug for u128impl<'a> Debug for Utf8Chunk<'a>impl Debug for poly16x4x2_timpl Debug for v128impl<I: Iterator + fmt::Debug, F, N: usize> Debug for MapWindows<I, F, N>impl Debug for DebugAsHeximpl<T: PointeeSized + Debug> Debug for &mut Timpl Debug for TryFromFloatSecsErrorimpl<Idx: fmt::Debug> Debug for RangeInclusive<Idx>impl Debug for Ipv4Addrimpl Debug for poly16x8x2_timpl Debug for vector_bool_charimpl<I: $crate::fmt::Debug> Debug for Cloned<I>impl<A: Debug, B: Debug> Debug for Zip<A, B>impl Debug for strimpl<T: $crate::fmt::Debug> Debug for Ready<T>impl Debug for int32x2x2_timpl Debug for vector_bool_shortimpl Debug for Variantimpl<I: fmt::Debug, F> Debug for Map<I, F>impl<I: fmt::Debug, P> Debug for SkipWhile<I, P>impl<T: PointeeSized> Debug for *mut Timpl Debug for RawWakerVTableimpl Debug for int32x4x2_timpl Debug for vector_bool_intimpl Debug for ()impl Debug for Wakerimpl<Ptr: fmt::Debug> Debug for Pin<Ptr>impl Debug for uint32x2x2_timpl Debug for vector_unsigned_longimpl Debug for Strimpl<I: $crate::fmt::Debug + Iterator> Debug for Peekable<I>impl<I: fmt::Debug, St: fmt::Debug, F> Debug for Scan<I, St, F>impl<T: ?Sized + Debug> Debug for Ref<'_, T>impl<'a> Debug for EscapeAscii<'a>impl Debug for LayoutErrorimpl Debug for uint32x4x2_timpl Debug for f16x2impl Debug for Location<'_>impl Debug for Boolimpl<T> Debug for PhantomCovariant<T>impl<T: fmt::Debug, P> Debug for Split<'_, T, P>impl Debug for uint8x8_timpl Debug for float16x4x2_timpl Debug for m256dimpl<'a> Debug for Request<'a>impl Debug for SimdAlignimpl<T: fmt::Debug, P> Debug for SplitInclusiveMut<'_, T, P>impl Debug for uint16x4_timpl Debug for float16x8x2_timpl Debug for m128dimpl<I: $crate::fmt::Debug> Debug for Fuse<I>impl Debug for Referenceimpl<T: fmt::Debug, P> Debug for SplitN<'_, T, P>impl Debug for uint32x2_timpl Debug for float32x2x2_timpl Debug for vector_bool_charimpl<T: ?Sized + Debug> Debug for RefMut<'_, T>impl Debug for CharTryFromErrorimpl<T: fmt::Debug, P> Debug for RSplitNMut<'_, T, P>impl Debug for uint64x1_timpl<F> Debug for OnceWith<F>impl Debug for float32x4x2_timpl Debug for vector_bool_shortimpl<T> Debug for PhantomContravariant<T>impl Debug for EscapeUnicodeimpl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksMut<'a, T>impl Debug for uint8x16_timpl Debug for int64x1x2_timpl Debug for vector_bool_intimpl<T: ?Sized> Debug for Exclusive<T>impl Debug for Pointerimpl<'a, T: $crate::fmt::Debug + 'a, N: usize> Debug for ArrayWindows<'a, T, N>impl Debug for ToUppercaseimpl Debug for uint16x8_timpl Debug for CStrimpl Debug for int64x2x2_timpl<T, F> Debug for DropGuard<T, F>impl Debug for vector_bool_long_longimpl<I: fmt::Debug, P> Debug for Filter<I, P>impl Debug for Enumimpl<T: ?Sized> Debug for PhantomData<T>impl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksExact<'a, T>impl Debug for uint32x4_timpl Debug for uint64x1x2_timpl Debug for HvxVectorimpl Debug for objc_selectorimpl<T: ?Sized> Debug for UnsafeCell<T>impl<'a, T: 'a + fmt::Debug, P> Debug for ChunkByMut<'a, T, P>impl Debug for uint64x2_timpl Debug for Ipv6MulticastScopeimpl Debug for uint64x2x2_timpl Debug for HvxVectorimpl<T> Debug for PhantomInvariant<T>impl<F: FnPtr> Debug for Fimpl Debug for ParseBoolErrorimpl Debug for float16x8_timpl<Idx: fmt::Debug> Debug for RangeToInclusive<Idx>impl Debug for poly64x1x2_timpl Debug for SocketAddrV4impl<'a, I: $crate::fmt::Debug> Debug for ByRefSized<'a, I>impl<T, N: usize> Debug for Simd<T, N>impl Debug for FpCategoryimpl<T: Copy + Debug> Debug for Cell<T>impl Debug for dyn Any + Send + Syncimpl<'a> Debug for Bytes<'a>impl Debug for int8x8x4_timpl<T> Debug for MaybeUninit<T>impl Debug for poly64x2x2_timpl<'a, A: $crate::fmt::Debug + 'a> Debug for IterMut<'a, A>impl<T: fmt::Debug> Debug for Saturating<T>impl<T: fmt::Debug, F> Debug for LazyCell<T, F>impl Debug for AtomicU8impl<'a, P> Debug for SplitTerminator<'a, P>impl Debug for int8x16x4_timpl Debug for FromBytesUntilNulErrorimpl Debug for __m128iimpl<I: fmt::Debug, F> Debug for FilterMap<I, F>impl Debug for AtomicI32impl<'a, P> Debug for RSplitN<'a, P>impl Debug for uint8x8x4_timpl Debug for __m256iimpl<I: $crate::fmt::Debug> Debug for Enumerate<I>impl Debug for Abiimpl Debug for AtomicU64impl<'a, P> Debug for Matches<'a, P>impl Debug for uint8x16x4_timpl Debug for __m512iimpl Debug for Infallibleimpl<T: $crate::fmt::Debug + PointeeSized> Debug for TraitImpl<T>impl<Idx: $crate::fmt::Debug> Debug for Clamp<Idx>impl Debug for AtomicBoolimpl Debug for EscapeDebugimpl<'a> Debug for LinesAny<'a>impl Debug for IpAddrimpl Debug for poly8x8x4_timpl Debug for __m128bhimpl<I: fmt::Debug, P> Debug for TakeWhile<I, P>impl Debug for f64impl<'a, P: Pattern<Searcher<'a>: fmt::Debug>> Debug for SplitInclusive<'a, P>impl Debug for poly8x16x4_timpl Debug for Ipv6Addrimpl Debug for __m128himpl<T: ?Sized + Debug> Debug for RefCell<T>impl<I: $crate::fmt::Debug> Debug for Skip<I>impl Debug for i8impl<'a> Debug for EscapeDefault<'a>impl<T: ?Sized> Debug for UnsafePinned<T>impl<A: $crate::fmt::Debug> Debug for RangeIter<A>impl Debug for int16x4x4_timpl Debug for bf16impl Debug for Lifetimeimpl Debug for i64impl Debug for SearchStepimpl Debug for int16x8x4_timpl Debug for float64x2_timpl Debug for objc_classimpl Debug for u8impl<'a, 'b, N: usize> Debug for CharArrayRefSearcher<'a, 'b, N>impl Debug for uint16x4x4_timpl Debug for VaList<'_>impl Debug for float64x1x4_timpl Debug for Fieldimpl Debug for u64impl<'a, 'b> Debug for StrSearcher<'a, 'b>impl Debug for uint16x8x4_timpl Debug for float64x2x4_timpl Debug for PanicMessage<'_>impl Debug for BorrowMutErrorimpl<T: PointeeSized + Debug> Debug for &Timpl Debug for Durationimpl Debug for poly16x4x4_timpl Debug for vector_unsigned_charimpl<'a, A: $crate::fmt::Debug + 'a> Debug for Iter<'a, A>impl Debug for EscapeDefaultimpl Debug for boolimpl<F> Debug for PollFn<F>impl<F> Debug for FromFn<F>impl Debug for poly16x8x4_timpl Debug for vector_unsigned_shortimpl<T: fmt::Debug> Debug for Wrapping<T>impl Debug for TryFromSliceErrorimpl Debug for Arrayimpl<I, U> Debug for Flatten<I>impl Debug for RangeFullimpl<T: PointeeSized> Debug for NonNull<T>impl<T: PointeeSized> Debug for *const Timpl Debug for RawWakerimpl Debug for int32x2x4_timpl Debug for vector_unsigned_intimpl<Idx: fmt::Debug> Debug for Range<Idx>impl<T: Debug> Debug for [T]impl<'a> Debug for ContextBuilder<'a>impl Debug for int32x4x4_timpl Debug for vector_signed_longimpl<F> Debug for FromFn<F>impl<H> Debug for BuildHasherDefault<H>impl Debug for Layoutimpl<T: $crate::fmt::Debug> Debug for Once<T>impl<T: $crate::fmt::Debug + ?Sized> Debug for ManuallyDrop<T>impl Debug for uint32x2x4_timpl Debug for Assumeimpl Debug for vector_doubleimpl Debug for TypeKindimpl Debug for Structimpl<T: fmt::Debug> Debug for IterMut<'_, T>impl<T> Debug for Empty<T>impl Debug for int8x8_timpl Debug for uint32x4x4_timpl Debug for m256impl Debug for AtomicOrderingimpl<T: fmt::Debug, P> Debug for SplitMut<'_, T, P>impl Debug for int16x4_timpl<'a> Debug for Bytes<'a>impl Debug for float16x4x4_timpl Debug for m128impl<I: $crate::fmt::Debug + Iterator> Debug for Intersperse<I>impl<T: fmt::Debug, P> Debug for RSplitMut<'_, T, P>impl Debug for int32x2_timpl Debug for Orderingimpl Debug for float16x8x4_timpl Debug for ParseFloatErrorimpl Debug for SocketAddrV6impl Debug for vector_unsigned_charimpl Debug for Tupleimpl Debug for Unionimpl Debug for Localityimpl Debug for Charimpl<T: fmt::Debug, P> Debug for SplitNMut<'_, T, P>impl Debug for int64x1_timpl Debug for Alignmentimpl Debug for float32x2x4_timpl Debug for vector_unsigned_shortimpl<'a> Debug for PanicInfo<'a>impl<'a, T: $crate::fmt::Debug + 'a> Debug for Chunks<'a, T>impl Debug for int8x16_timpl Debug for float32x4x4_timpl Debug for vector_unsigned_intimpl<'a> Debug for Source<'a>impl<T: $crate::fmt::Debug> Debug for Rev<T>impl Debug for BorrowErrorimpl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksExactMut<'a, T>impl<G> Debug for FromCoroutine<G>impl Debug for int16x8_timpl Debug for int64x1x4_timpl Debug for vector_unsigned_long_longimpl Debug for Intimpl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksMut<'a, T>impl Debug for int32x4_timpl<T: $crate::fmt::Debug> Debug for Bound<T>impl<T: $crate::fmt::Debug> Debug for Reverse<T>impl<F> Debug for RepeatWith<F>impl Debug for int64x2x4_timpl<Idx: fmt::Debug> Debug for RangeToInclusive<Idx>impl Debug for vector_doubleimpl Debug for GenericTypeimpl<T: fmt::Debug> Debug for AssertUnwindSafe<T>impl<'a, T: 'a + fmt::Debug, P> Debug for ChunkBy<'a, T, P>impl Debug for int64x2_timpl<Idx: fmt::Debug> Debug for RangeInclusive<Idx>impl Debug for uint64x1x4_timpl Debug for HvxVectorPredimpl<T> Debug for Discriminant<T>impl Debug for Utf8Errorimpl Debug for float16x4_timpl<A: $crate::fmt::Debug> Debug for RangeFromIter<A>impl<A: $crate::fmt::Debug> Debug for Repeat<A>impl Debug for uint64x2x4_timpl Debug for BorrowedBuf<'_>impl<'a, T: $crate::fmt::Debug + 'a> Debug for Iter<'a, T>impl Debug for HvxVectorPredimpl Debug for FnPtrimpl Debug for PhantomInvariantLifetime<'_>impl Debug for dyn Any + Sendimpl<'a> Debug for CharIndices<'a>impl Debug for int8x8x3_timpl Debug for IntErrorKindimpl Debug for poly64x1x4_timpl Debug for Typeimpl Debug for TypeIdimpl Debug for AtomicI8impl<'a, P> Debug for RSplit<'a, P>impl Debug for int8x16x3_timpl Debug for AddrParseErrorimpl Debug for poly64x2x4_timpl<F> Debug for fn(_: T) -> Retimpl Debug for AtomicU16impl<'a, P> Debug for SplitN<'a, P>impl Debug for ToTitlecaseimpl Debug for uint8x8x3_timpl Debug for __m128dimpl Debug for Sliceimpl Debug for AtomicI64impl<Idx: fmt::Debug> Debug for RangeFrom<Idx>impl<'a, P> Debug for RMatchIndices<'a, P>impl Debug for uint8x16x3_timpl Debug for __m256dimpl<'a> Debug for BorrowedCursor<'a>impl Debug for Errorimpl Debug for ParseCharErrorimpl Debug for AtomicUsizeimpl<'a> Debug for Lines<'a>impl Debug for poly8x8x3_timpl<Idx: fmt::Debug> Debug for RangeFrom<Idx>impl Debug for __m512dimpl Debug for AsciiCharimpl<B: $crate::fmt::Debug, C: $crate::fmt::Debug> Debug for ControlFlow<B, C>impl<Dyn: PointeeSized> Debug for DynMetadata<Dyn>impl Debug for f32impl<'a> Debug for SplitAsciiWhitespace<'a>impl Debug for poly8x16x3_timpl Debug for __m512bhimpl<A: $crate::fmt::Debug> Debug for OptionFlatten<A>impl Debug for DynTraitimpl Debug for f128impl<'a> Debug for EscapeDebug<'a>impl Debug for int16x4x3_timpl Debug for __m512himpl<I: fmt::Debug, U, F> Debug for FlatMap<I, U, F>impl Debug for i32impl<'a> Debug for Utf8Pattern<'a>impl Debug for int16x8x3_timpl Debug for ParseIntErrorimpl Debug for float64x1_timpl Debug for PhantomContravariantLifetime<'_>impl Debug for isizeimpl<'a, N: usize> Debug for CharArraySearcher<'a, N>impl Debug for uint16x4x3_timpl Debug for float64x1x3_timpl<T: fmt::Debug, N: usize> Debug for IntoIter<T, N>impl Debug for DynTraitPredicateimpl<I, G> Debug for IntersperseWith<I, G>impl Debug for u32impl<F> Debug for CharPredicateSearcher<'_, F>impl Debug for uint16x8x3_timpl Debug for float64x2x3_timpl<I: $crate::fmt::Debug> Debug for FromIter<I>impl<Y: $crate::fmt::Debug, R: $crate::fmt::Debug> Debug for CoroutineState<Y, R>impl Debug for usizeimpl Debug for Utf8Chunks<'_>impl Debug for poly16x4x3_timpl Debug for vector_signed_charimpl<I: $crate::fmt::Debug> Debug for Cycle<I>impl Debug for neverimpl<T> Debug for Pending<T>impl Debug for FromBytesWithNulErrorimpl Debug for poly16x8x3_timpl Debug for vector_signed_shortimpl Debug for Traitimpl Debug for Floatimpl<T> Debug for NonZero<T>impl Debug for charimpl Debug for EscapeDefaultimpl<T: $crate::fmt::Debug> Debug for Poll<T>impl Debug for TryFromIntErrorimpl Debug for int32x2x3_timpl Debug for vector_signed_intimpl Debug for Constimpl Debug for Alignmentimpl Debug for DecodeUtf16Errorimpl<T: Debug> Debug for (T)impl Debug for Context<'_>impl Debug for TryFromCharErrorimpl Debug for int32x4x3_timpl Debug for vector_floatimpl<'a, T: $crate::fmt::Debug + 'a> Debug for IterMut<'a, T>impl Debug for SipHasherimpl Debug for LocalWakerimpl Debug for uint32x2x3_timpl<T: fmt::Debug, F> Debug for Successors<T, F>impl Debug for vector_bool_longimpl Debug for PhantomPinnedimpl<T: fmt::Debug> Debug for Iter<'_, T>impl Debug for AllocErrorimpl Debug for uint32x4x3_timpl Debug for m256iimpl<T: $crate::fmt::Debug> Debug for IntoIter<T>impl Debug for PhantomCovariantLifetime<'_>impl Debug for FormattingOptionsimpl<T: fmt::Debug, P> Debug for SplitInclusive<'_, T, P>impl Debug for poly8x8_timpl Debug for CharCaseimpl<Idx: fmt::Debug> Debug for Range<Idx>impl<A: fmt::Debug> Debug for RepeatN<A>impl Debug for float16x4x3_timpl Debug for m128iimpl<T: fmt::Debug, P> Debug for RSplit<'_, T, P>impl Debug for poly16x4_timpl Debug for float16x8x3_timpl Debug for vector_signed_charimpl<I: fmt::Debug, P> Debug for MapWhile<I, P>impl<T: fmt::Debug> Debug for OnceCell<T>impl<T: fmt::Debug, P> Debug for RSplitN<'_, T, P>impl Debug for float32x2_timpl Debug for float32x2x3_timpl Debug for vector_signed_shortimpl<'a, T: $crate::fmt::Debug + 'a> Debug for Windows<'a, T>impl Debug for poly64x1_timpl Debug for float32x4x3_timpl Debug for c_voidimpl Debug for vector_signed_intimpl<'a, T: $crate::fmt::Debug + 'a> Debug for ChunksExact<'a, T>impl Debug for poly8x16_timpl Debug for int64x1x3_timpl Debug for vector_signed_long_longimpl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunks<'a, T>impl Debug for poly16x8_timpl Debug for int64x2x3_timpl<T: $crate::fmt::Debug, E: $crate::fmt::Debug> Debug for Result<T, E>impl Debug for vector_floatimpl<T: $crate::fmt::Debug + NumBufferTrait> Debug for NumBuffer<T>impl<I: $crate::fmt::Debug> Debug for Take<I>impl<'a, T: $crate::fmt::Debug + 'a> Debug for RChunksExactMut<'a, T>impl Debug for float32x4_timpl Debug for uint64x1x3_timpl Debug for HvxVectorPairimpl Debug for Arguments<'_>impl Debug for GetDisjointMutErrorimpl Debug for poly64x2_timpl Debug for uint64x2x3_timpl Debug for HvxVectorPairimpl<I: fmt::Debug, F> Debug for Inspect<I, F>impl Debug for dyn Anyimpl Debug for Chars<'_>impl Debug for int8x8x2_timpl Debug for poly64x1x3_timpl<T, N: usize> Debug for Mask<T, N>impl<T: fmt::Debug, N: usize> Debug for [T; N]impl<'a, P> Debug for Split<'a, P>impl<Idx: fmt::Debug> Debug for RangeTo<Idx>impl Debug for int8x16x2_timpl Debug for poly64x2x3_timpl<T: ?Sized> Debug for SyncUnsafeCell<T>impl Debug for AtomicI16impl<'a, P> Debug for RSplitTerminator<'a, P>impl Debug for uint8x8x2_timpl Debug for __m128impl Debug for Orderingimpl Debug for AtomicU32impl<'a, P> Debug for MatchIndices<'a, P>impl Debug for uint8x16x2_timpl Debug for __m256impl<A: $crate::fmt::Debug> Debug for IntoIter<A>impl Debug for AtomicIsizeimpl<'a, P> Debug for RMatches<'a, P>impl Debug for poly8x8x2_timpl Debug for __m512impl<I: $crate::fmt::Debug> Debug for Copied<I>