Trait tendermint::consensus::state::fmt::Debug 1.0.0[−][src]
Expand description
?
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
derive
d 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
enum
s, 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 (libstd
, libcore
, liballoc
, etc.) are not stable, and
may also change with future Rust versions.
Examples
Deriving an implementation:
#[derive(Debug)] struct Point { x: i32, y: i32, } let origin = Point { x: 0, y: 0 }; assert_eq!(format!("The origin is: {:?}", origin), "The origin is: Point { x: 0, y: 0 }");
Manually implementing:
use std::fmt; struct Point { x: i32, y: i32, } impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Point") .field("x", &self.x) .field("y", &self.y) .finish() } } let origin = Point { x: 0, y: 0 }; assert_eq!(format!("The origin is: {:?}", origin), "The origin is: Point { x: 0, y: 0 }");
There are a number of helper methods on the Formatter
struct 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 }; assert_eq!(format!("The origin is: {:#?}", origin), "The origin is: Point { x: 0, y: 0, }");
Required methods
Formats the value using the given formatter.
Examples
use std::fmt; struct Position { longitude: f32, latitude: f32, } impl fmt::Debug for Position { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("") .field(&self.longitude) .field(&self.latitude) .finish() } } let position = Position { longitude: 1.987, latitude: 2.983 }; assert_eq!(format!("{:?}", position), "(1.987, 2.983)"); assert_eq!(format!("{:#?}", position), "( 1.987, 2.983, )");
Implementations on Foreign Types
1.16.0[src]impl<'_, T, S> Debug for SymmetricDifference<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
impl<'_, T, S> Debug for SymmetricDifference<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
1.16.0[src]impl<'_, T, S> Debug for Intersection<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
impl<'_, T, S> Debug for Intersection<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
1.16.0[src]impl<'_, T, S> Debug for Difference<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
impl<'_, T, S> Debug for Difference<'_, T, S> where
S: BuildHasher,
T: Debug + Eq + Hash,
1.9.0[src]impl<I, U, F> Debug for FlatMap<I, U, F> where
I: Debug,
U: IntoIterator,
<U as IntoIterator>::IntoIter: Debug,
impl<I, U, F> Debug for FlatMap<I, U, F> where
I: Debug,
U: IntoIterator,
<U as IntoIterator>::IntoIter: Debug,
impl<'data, 'file, Mach, R> Debug for MachOSectionIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl<'data, 'file, Mach, R> Debug for MachOSectionIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl<'data, 'file, Elf> Debug for ElfSymbolIterator<'data, 'file, Elf> where
Elf: FileHeader,
impl<'data, 'file, Elf> Debug for ElfSymbolIterator<'data, 'file, Elf> where
Elf: FileHeader,
impl<'data> Debug for SymbolTable<'data>
impl<'data> Debug for SymbolTable<'data>
impl Debug for ImageDynamicRelocation64
impl Debug for ImageDynamicRelocation64
impl<E> Debug for I32Bytes<E> where
E: Endian,
impl<E> Debug for I32Bytes<E> where
E: Endian,
impl Debug for ImageRuntimeFunctionEntry
impl Debug for ImageRuntimeFunctionEntry
impl Debug for ImageAuxSymbolFunctionBeginEnd
impl Debug for ImageAuxSymbolFunctionBeginEnd
impl<'data, 'file, Mach, R> Debug for MachOSymbolIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl<'data, 'file, Mach, R> Debug for MachOSymbolIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl Debug for ImageResourceDirectoryString
impl Debug for ImageResourceDirectoryString
impl Debug for ImageLoadConfigCodeIntegrity
impl Debug for ImageLoadConfigCodeIntegrity
impl<'data, 'file> Debug for CoffSymbolTable<'data, 'file>
impl<'data, 'file> Debug for CoffSymbolTable<'data, 'file>
impl Debug for ImageArmRuntimeFunctionEntry
impl Debug for ImageArmRuntimeFunctionEntry
impl<'data, 'file> Debug for CoffSymbolIterator<'data, 'file>
impl<'data, 'file> Debug for CoffSymbolIterator<'data, 'file>
impl Debug for ImageBoundImportDescriptor
impl Debug for ImageBoundImportDescriptor
impl<'data, 'file, R> Debug for Symbol<'data, 'file, R> where
R: ReadRef<'data>,
impl<'data, 'file, R> Debug for Symbol<'data, 'file, R> where
R: ReadRef<'data>,
impl Debug for ImageLoadConfigDirectory64
impl Debug for ImageLoadConfigDirectory64
impl<'data, 'file, Elf, R> Debug for ElfDynamicRelocationIterator<'data, 'file, Elf, R> where
R: ReadRef<'data>,
Elf: FileHeader,
impl<'data, 'file, Elf, R> Debug for ElfDynamicRelocationIterator<'data, 'file, Elf, R> where
R: ReadRef<'data>,
Elf: FileHeader,
impl<'data> Debug for SectionTable<'data>
impl<'data> Debug for SectionTable<'data>
impl Debug for ImageDynamicRelocation32
impl Debug for ImageDynamicRelocation32
impl<E> Debug for I16Bytes<E> where
E: Endian,
impl<E> Debug for I16Bytes<E> where
E: Endian,
impl Debug for ImageSeparateDebugHeader
impl Debug for ImageSeparateDebugHeader
impl Debug for ImageLoadConfigDirectory32
impl Debug for ImageLoadConfigDirectory32
impl<E> Debug for U64Bytes<E> where
E: Endian,
impl<E> Debug for U64Bytes<E> where
E: Endian,
impl<E> Debug for U16Bytes<E> where
E: Endian,
impl<E> Debug for U16Bytes<E> where
E: Endian,
impl<'data, 'file, Mach, R> Debug for MachORelocationIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl<'data, 'file, Mach, R> Debug for MachORelocationIterator<'data, 'file, Mach, R> where
R: ReadRef<'data>,
Mach: MachHeader,
impl<'data, 'file> Debug for CoffSymbol<'data, 'file>
impl<'data, 'file> Debug for CoffSymbol<'data, 'file>
impl<'data> Debug for ObjectMapEntry<'data>
impl<'data> Debug for ObjectMapEntry<'data>
impl<'data, 'file, R> Debug for Section<'data, 'file, R> where
R: ReadRef<'data>,
impl<'data, 'file, R> Debug for Section<'data, 'file, R> where
R: ReadRef<'data>,
impl Debug for ImagePrologueDynamicRelocationHeader
impl Debug for ImagePrologueDynamicRelocationHeader
impl Debug for ImageArm64RuntimeFunctionEntry
impl Debug for ImageArm64RuntimeFunctionEntry
impl<'data, 'file, Elf, R> Debug for ElfSectionRelocationIterator<'data, 'file, Elf, R> where
R: ReadRef<'data>,
Elf: FileHeader,
impl<'data, 'file, Elf, R> Debug for ElfSectionRelocationIterator<'data, 'file, Elf, R> where
R: ReadRef<'data>,
Elf: FileHeader,
impl Debug for ImageDynamicRelocation64V2
impl Debug for ImageDynamicRelocation64V2
impl Debug for ImageArchiveMemberHeader
impl Debug for ImageArchiveMemberHeader
impl Debug for ImageDelayloadDescriptor
impl Debug for ImageDelayloadDescriptor
impl Debug for ImageResourceDirectoryEntry
impl Debug for ImageResourceDirectoryEntry
impl<'data, 'table> Debug for SymbolIterator<'data, 'table>
impl<'data, 'table> Debug for SymbolIterator<'data, 'table>
impl<'data> Debug for StringTable<'data>
impl<'data> Debug for StringTable<'data>
impl<'data> Debug for SymbolMapName<'data>
impl<'data> Debug for SymbolMapName<'data>
impl<E> Debug for I64Bytes<E> where
E: Endian,
impl<E> Debug for I64Bytes<E> where
E: Endian,
impl<'data, 'file, R> Debug for Comdat<'data, 'file, R> where
R: ReadRef<'data>,
impl<'data, 'file, R> Debug for Comdat<'data, 'file, R> where
R: ReadRef<'data>,
impl Debug for ImageAlphaRuntimeFunctionEntry
impl Debug for ImageAlphaRuntimeFunctionEntry
impl Debug for ImageEpilogueDynamicRelocationHeader
impl Debug for ImageEpilogueDynamicRelocationHeader
impl<'data, 'file, R> Debug for Segment<'data, 'file, R> where
R: ReadRef<'data>,
impl<'data, 'file, R> Debug for Segment<'data, 'file, R> where
R: ReadRef<'data>,
impl Debug for ImageDynamicRelocationTable
impl Debug for ImageDynamicRelocationTable
impl<'data> Debug for ArchiveMember<'data>
impl<'data> Debug for ArchiveMember<'data>
impl<'data, 'file, R> Debug for CoffRelocationIterator<'data, 'file, R> where
R: ReadRef<'data>,
impl<'data, 'file, R> Debug for CoffRelocationIterator<'data, 'file, R> where
R: ReadRef<'data>,
impl Debug for ImageDynamicRelocation32V2
impl Debug for ImageDynamicRelocation32V2
impl<E> Debug for U32Bytes<E> where
E: Endian,
impl<E> Debug for U32Bytes<E> where
E: Endian,
impl<'data> Debug for CompressedData<'data>
impl<'data> Debug for CompressedData<'data>
impl Debug for ImageAlpha64RuntimeFunctionEntry
impl Debug for ImageAlpha64RuntimeFunctionEntry
impl Debug for NoDynamicRelocationIterator
impl Debug for NoDynamicRelocationIterator
impl<'h, 'n> Debug for FindIter<'h, 'n>
impl<'h, 'n> Debug for FindIter<'h, 'n>
impl<'h, 'n> Debug for FindRevIter<'h, 'n>
impl<'h, 'n> Debug for FindRevIter<'h, 'n>
The Debug
output of the naive date d
is the same as
d.format("%Y-%m-%d")
.
The string printed can be readily parsed via the parse
method on str
.
Example
use chrono::NaiveDate; assert_eq!(format!("{:?}", NaiveDate::from_ymd(2015, 9, 5)), "2015-09-05"); assert_eq!(format!("{:?}", NaiveDate::from_ymd( 0, 1, 1)), "0000-01-01"); assert_eq!(format!("{:?}", NaiveDate::from_ymd(9999, 12, 31)), "9999-12-31");
ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.
assert_eq!(format!("{:?}", NaiveDate::from_ymd( -1, 1, 1)), "-0001-01-01"); assert_eq!(format!("{:?}", NaiveDate::from_ymd(10000, 12, 31)), "+10000-12-31");
The Debug
output of the naive date and time dt
is the same as
dt.format("%Y-%m-%dT%H:%M:%S%.f")
.
The string printed can be readily parsed via the parse
method on str
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
Example
use chrono::NaiveDate; let dt = NaiveDate::from_ymd(2016, 11, 15).and_hms(7, 39, 24); assert_eq!(format!("{:?}", dt), "2016-11-15T07:39:24");
Leap seconds may also be used.
let dt = NaiveDate::from_ymd(2015, 6, 30).and_hms_milli(23, 59, 59, 1_500); assert_eq!(format!("{:?}", dt), "2015-06-30T23:59:60.500");
The Debug
output of the ISO week w
is the same as
d.format("%G-W%V")
where d
is any NaiveDate
value in that week.
Example
use chrono::{NaiveDate, Datelike}; assert_eq!(format!("{:?}", NaiveDate::from_ymd(2015, 9, 5).iso_week()), "2015-W36"); assert_eq!(format!("{:?}", NaiveDate::from_ymd( 0, 1, 3).iso_week()), "0000-W01"); assert_eq!(format!("{:?}", NaiveDate::from_ymd(9999, 12, 31).iso_week()), "9999-W52");
ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.
assert_eq!(format!("{:?}", NaiveDate::from_ymd( 0, 1, 2).iso_week()), "-0001-W52"); assert_eq!(format!("{:?}", NaiveDate::from_ymd(10000, 12, 31).iso_week()), "+10000-W52");
The Debug
output of the naive time t
is the same as
t.format("%H:%M:%S%.f")
.
The string printed can be readily parsed via the parse
method on str
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
Example
use chrono::NaiveTime; assert_eq!(format!("{:?}", NaiveTime::from_hms(23, 56, 4)), "23:56:04"); assert_eq!(format!("{:?}", NaiveTime::from_hms_milli(23, 56, 4, 12)), "23:56:04.012"); assert_eq!(format!("{:?}", NaiveTime::from_hms_micro(23, 56, 4, 1234)), "23:56:04.001234"); assert_eq!(format!("{:?}", NaiveTime::from_hms_nano(23, 56, 4, 123456)), "23:56:04.000123456");
Leap seconds may also be used.
assert_eq!(format!("{:?}", NaiveTime::from_hms_milli(6, 59, 59, 1_500)), "06:59:60.500");
Debug the serialization of this URL.
impl<'text> Debug for InitialInfo<'text>
impl<'text> Debug for InitialInfo<'text>
impl<X> Debug for WeightedIndex<X> where
X: Debug + SampleUniform + PartialOrd<X>,
<X as SampleUniform>::Sampler: Debug,
impl<X> Debug for WeightedIndex<X> where
X: Debug + SampleUniform + PartialOrd<X>,
<X as SampleUniform>::Sampler: Debug,
impl<X> Debug for Uniform<X> where
X: Debug + SampleUniform,
<X as SampleUniform>::Sampler: Debug,
impl<X> Debug for Uniform<X> where
X: Debug + SampleUniform,
<X as SampleUniform>::Sampler: Debug,
impl<R, Rsdr> Debug for ReseedingRng<R, Rsdr> where
R: Debug + BlockRngCore + SeedableRng,
Rsdr: Debug + RngCore,
impl<R, Rsdr> Debug for ReseedingRng<R, Rsdr> where
R: Debug + BlockRngCore + SeedableRng,
Rsdr: Debug + RngCore,
impl<C> Debug for EncodedPoint<C> where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: Add<UInt<UTerm, B1>>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
impl<C> Debug for EncodedPoint<C> where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: Add<UInt<UTerm, B1>>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
impl<C> Debug for Signature<C> where
C: Curve,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: ArrayLength<u8>,
impl<C> Debug for Signature<C> where
C: Curve,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output: ArrayLength<u8>,