Merge pull request #1843 from embassy-rs/fmt-sync
Sync all fmt.rs files.
This commit is contained in:
		| @@ -83,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -226,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub struct Bytes<'a>(pub &'a [u8]); | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -93,7 +93,7 @@ macro_rules! unreachable { | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*); | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -229,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub struct Bytes<'a>(pub &'a [u8]); | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|   | ||||
| @@ -93,7 +93,7 @@ macro_rules! unreachable { | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*); | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -229,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub struct Bytes<'a>(pub &'a [u8]); | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #![macro_use] | ||||
| #![allow(unused_macros)] | ||||
|  | ||||
| use core::fmt::{Debug, Display, LowerHex}; | ||||
|  | ||||
| #[cfg(all(feature = "defmt", feature = "log"))] | ||||
| compile_error!("You may not enable both `defmt` and `log` features."); | ||||
|  | ||||
| @@ -81,14 +83,17 @@ macro_rules! todo { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(not(feature = "defmt"))] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         { | ||||
|             #[cfg(not(feature = "defmt"))] | ||||
|             ::core::unreachable!($($x)*); | ||||
|             #[cfg(feature = "defmt")] | ||||
|             ::defmt::unreachable!($($x)*); | ||||
|         } | ||||
|         ::core::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| macro_rules! unreachable { | ||||
|     ($($x:tt)*) => { | ||||
|         ::defmt::unreachable!($($x)*) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | ||||
|         self | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(unused)] | ||||
| pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||||
|  | ||||
| impl<'a> Debug for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> Display for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> LowerHex for Bytes<'a> { | ||||
|     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||
|         write!(f, "{:#02x?}", self.0) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "defmt")] | ||||
| impl<'a> defmt::Format for Bytes<'a> { | ||||
|     fn format(&self, fmt: defmt::Formatter) { | ||||
|         defmt::write!(fmt, "{:02x}", self.0) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user