RKTK API Docs RKTK Home Repo

rktk_log/
helper.rs

1#[derive(Debug)]
2pub struct Debug2Format<'a, T: core::fmt::Debug + ?Sized>(pub &'a T);
3
4#[cfg(feature = "defmt")]
5impl<T: core::fmt::Debug + ?Sized> defmt::Format for Debug2Format<'_, T> {
6    fn format(&self, f: defmt::Formatter<'_>) {
7        defmt::Debug2Format(self.0).format(f)
8    }
9}
10
11pub struct Display2Format<'a, T: core::fmt::Display + ?Sized>(pub &'a T);
12
13impl<T: core::fmt::Display + ?Sized> core::fmt::Display for Display2Format<'_, T> {
14    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
15        core::fmt::Display::fmt(&self.0, f)
16    }
17}
18
19#[cfg(feature = "defmt")]
20impl<T: core::fmt::Display + ?Sized> defmt::Format for Display2Format<'_, T> {
21    fn format(&self, f: defmt::Formatter<'_>) {
22        defmt::Display2Format(self.0).format(f)
23    }
24}