diff --git a/src/impls.rs b/src/impls.rs index d112d031..8a4c8191 100644 --- a/src/impls.rs +++ b/src/impls.rs @@ -488,3 +488,107 @@ where Format::format(&(*self as *const T), fmt) } } + +// core::ops + +impl Format for core::ops::Range +where + Idx: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "{}..{}", self.start, self.end) + } +} + +impl Format for core::ops::RangeFrom +where + Idx: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "{}..", self.start) + } +} + +impl Format for core::ops::RangeFull { + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "..",) + } +} + +impl Format for core::ops::RangeInclusive +where + Idx: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "{}..={}", self.start(), self.end()) + } +} + +impl Format for core::ops::RangeTo +where + Idx: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "..{}", self.end) + } +} + +impl Format for core::ops::RangeToInclusive +where + Idx: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "..={}", self.end) + } +} + +// core::iter + +// Some of these objects don't expose enough to accurately report their debug state. In this case +// we show as much state as we can. Users can always use `Debug2Format` to get more information, at +// the cost of bringing core::fmt into the firmware and doing the layout work on device. + +// keep the type parameter trait bounds in case it becomes possible use this later, without making +// a backwards-incompatible change. +impl Format for core::iter::Zip +where + A: Format, + B: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "Zip(..)") + } +} + +// core::slice + +impl<'a, T: 'a> Format for core::slice::ChunksExact<'a, T> +where + T: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "ChunksExact(..)") + } +} + +impl<'a, T: 'a> Format for core::slice::Iter<'a, T> +where + T: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!( + fmt, + "Iter {{ slice: {=[?]}, position: ? }}", + self.as_slice() + ) + } +} + +impl<'a, T: 'a> Format for core::slice::Windows<'a, T> +where + T: Format, +{ + fn format(&self, fmt: Formatter) { + defmt::write!(fmt, "Windows(..)") + } +}