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