pub trait DebugExt {
type Ctx;
// Required method
fn fmt_with(&self, f: &mut Formatter<'_>, ctx: &Self::Ctx) -> FmtResult<()>;
// Provided method
fn debug_with<'a>(&'a self, ctx: &'a Self::Ctx) -> DebugWith<'a, Self>
where Self: Sized { ... }
}Expand description
๐น ๐ Extension for contextual debugging.
๐ text/fmt
Types implementing this trait support formatting with a caller-supplied context.
The context is defined per-type via the Ctx associated type, allowing each type
to expose whatever formatting modes it needs without affecting other types.
ยงExamples
enum Mode { Hex, Dec }
struct Value(u32);
impl DebugExt for Value {
type Ctx = Mode;
fn fmt_with(&self, f: &mut Formatter, mode: &Self::Ctx) -> FmtResult<()> {
match mode {
Mode::Hex => write!(f, "0x{:X}", self.0),
Mode::Dec => write!(f, "{}", self.0),
}
}
}
let v = Value(255);
// caller chooses representation:
// v.fmt_with(f, &Mode::Hex) โ "0xFF"
// v.fmt_with(f, &Mode::Dec) โ "255"Required Associated Typesยง
Required Methodsยง
Provided Methodsยง
Sourcefn debug_with<'a>(&'a self, ctx: &'a Self::Ctx) -> DebugWith<'a, Self>where
Self: Sized,
fn debug_with<'a>(&'a self, ctx: &'a Self::Ctx) -> DebugWith<'a, Self>where
Self: Sized,
Wraps self for contextual debug formatting.
Dyn Compatibilityยง
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementorsยง
Sourceยงimpl DebugExt for AppControlSetwhere
AppControlSet: Debug,
impl DebugExt for AppControlSetwhere
AppControlSet: Debug,
Sourceยงimpl DebugExt for BitfieldExamplewhere
BitfieldExample: Debug,
Available on crate features _docs_examples only.
impl DebugExt for BitfieldExamplewhere
BitfieldExample: Debug,
Available on crate features
_docs_examples only.Sourceยงimpl DebugExt for EnumSetExamplewhere
EnumSetExample: Debug,
Available on doc or test only.
impl DebugExt for EnumSetExamplewhere
EnumSetExample: Debug,
Available on
doc or test only.Sourceยงimpl DebugExt for EventButtonswhere
EventButtons: Debug,
Available on crate feature event only.
impl DebugExt for EventButtonswhere
EventButtons: Debug,
Available on crate feature
event only.Sourceยงimpl DebugExt for EventTagSetwhere
EventTagSet: Debug,
Available on crate feature event only.
impl DebugExt for EventTagSetwhere
EventTagSet: Debug,
Available on crate feature
event only.Sourceยงimpl DebugExt for EventTimestamp
Available on crate feature event only.
impl DebugExt for EventTimestamp
Available on crate feature
event only.type Ctx = EventTimestampMode
Sourceยงimpl DebugExt for LinuxSigactionFlagswhere
LinuxSigactionFlags: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxSigactionFlagswhere
LinuxSigactionFlags: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for LinuxSignalSetwhere
LinuxSignalSet: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxSignalSetwhere
LinuxSignalSet: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for LinuxTermiosControlFlagswhere
LinuxTermiosControlFlags: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxTermiosControlFlagswhere
LinuxTermiosControlFlags: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for LinuxTermiosInputFlagswhere
LinuxTermiosInputFlags: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxTermiosInputFlagswhere
LinuxTermiosInputFlags: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for LinuxTermiosLocalFlagswhere
LinuxTermiosLocalFlags: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxTermiosLocalFlagswhere
LinuxTermiosLocalFlags: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for LinuxTermiosOutputFlagswhere
LinuxTermiosOutputFlags: Debug,
Available on crate feature linux only.
impl DebugExt for LinuxTermiosOutputFlagswhere
LinuxTermiosOutputFlags: Debug,
Available on crate feature
linux only.Sourceยงimpl DebugExt for RandQualitieswhere
RandQualities: Debug,
impl DebugExt for RandQualitieswhere
RandQualities: Debug,
Sourceยงimpl DebugExt for RunCapInputwhere
RunCapInput: Debug,
impl DebugExt for RunCapInputwhere
RunCapInput: Debug,
Sourceยงimpl DebugExt for RunCapSystemwhere
RunCapSystem: Debug,
impl DebugExt for RunCapSystemwhere
RunCapSystem: Debug,
Sourceยงimpl DebugExt for RunCapTextwhere
RunCapText: Debug,
impl DebugExt for RunCapTextwhere
RunCapText: Debug,
Sourceยงimpl DebugExt for TermStyleExtwhere
TermStyleExt: Debug,
Available on crate feature term only.
impl DebugExt for TermStyleExtwhere
TermStyleExt: Debug,
Available on crate feature
term only.Sourceยงimpl DebugExt for TermelMetawhere
TermelMeta: Debug,
Available on crate feature term only.
impl DebugExt for TermelMetawhere
TermelMeta: Debug,
Available on crate feature
term only.