diff --git a/firmware/qemu/src/bin/log.out b/firmware/qemu/src/bin/log.out index 8fac0785..3a4002c3 100644 --- a/firmware/qemu/src/bin/log.out +++ b/firmware/qemu/src/bin/log.out @@ -125,4 +125,16 @@ 0.000124 INFO ChunksExact(..) 0.000125 INFO Iter { slice: [0, 1, 2], position: ? } 0.000126 INFO Windows(..) -0.000127 INFO QEMU test finished! +0.000127 INFO 1 +0.000128 INFO 1 +0.000129 INFO 1 +0.000130 INFO 1 +0.000131 INFO 1 +0.000132 INFO 1 +0.000133 INFO 1 +0.000134 INFO 1 +0.000135 INFO 1 +0.000136 INFO 1 +0.000137 INFO 1 +0.000138 INFO 1 +0.000139 INFO QEMU test finished! diff --git a/firmware/qemu/src/bin/log.release.out b/firmware/qemu/src/bin/log.release.out index 5d7357c1..8a55cf91 100644 --- a/firmware/qemu/src/bin/log.release.out +++ b/firmware/qemu/src/bin/log.release.out @@ -123,4 +123,16 @@ 0.000122 INFO ChunksExact(..) 0.000123 INFO Iter { slice: [0, 1, 2], position: ? } 0.000124 INFO Windows(..) -0.000125 INFO QEMU test finished! +0.000125 INFO 1 +0.000126 INFO 1 +0.000127 INFO 1 +0.000128 INFO 1 +0.000129 INFO 1 +0.000130 INFO 1 +0.000131 INFO 1 +0.000132 INFO 1 +0.000133 INFO 1 +0.000134 INFO 1 +0.000135 INFO 1 +0.000136 INFO 1 +0.000137 INFO QEMU test finished! diff --git a/firmware/qemu/src/bin/log.rs b/firmware/qemu/src/bin/log.rs index e8e3c002..572df7f9 100644 --- a/firmware/qemu/src/bin/log.rs +++ b/firmware/qemu/src/bin/log.rs @@ -3,6 +3,7 @@ use core::{ marker::PhantomData, + num, sync::atomic::{AtomicU32, Ordering}, }; use cortex_m_rt::entry; @@ -617,6 +618,20 @@ fn main() -> ! { defmt::info!("{:?}", [0, 1, 2].iter()); // ChunksExact defmt::info!("{:?}", [0, 1, 2].windows(1)); // Windows + // core::num::NonZero* + defmt::info!("{}", num::NonZeroI8::new(1).unwrap()); + defmt::info!("{}", num::NonZeroI16::new(1).unwrap()); + defmt::info!("{}", num::NonZeroI32::new(1).unwrap()); + defmt::info!("{}", num::NonZeroI64::new(1).unwrap()); + defmt::info!("{}", num::NonZeroI128::new(1).unwrap()); + defmt::info!("{}", num::NonZeroIsize::new(1).unwrap()); + defmt::info!("{}", num::NonZeroU8::new(1).unwrap()); + defmt::info!("{}", num::NonZeroU16::new(1).unwrap()); + defmt::info!("{}", num::NonZeroU32::new(1).unwrap()); + defmt::info!("{}", num::NonZeroU64::new(1).unwrap()); + defmt::info!("{}", num::NonZeroU128::new(1).unwrap()); + defmt::info!("{}", num::NonZeroUsize::new(1).unwrap()); + defmt::info!("QEMU test finished!"); loop { diff --git a/src/impls/core_/mod.rs b/src/impls/core_/mod.rs index 57ba6d65..4781cb89 100644 --- a/src/impls/core_/mod.rs +++ b/src/impls/core_/mod.rs @@ -5,6 +5,7 @@ //! We generally keep the type parameter trait bounds in case it becomes possible to use this //! later, without making a backwards-incompatible change. +mod num; mod ops; mod slice; diff --git a/src/impls/core_/num.rs b/src/impls/core_/num.rs new file mode 100644 index 00000000..10f9dc72 --- /dev/null +++ b/src/impls/core_/num.rs @@ -0,0 +1,26 @@ +use core::num; + +use super::*; + +macro_rules! non_zero { + ($type:ty, $hint:literal) => { + impl Format for $type { + fn format(&self, fmt: Formatter) { + crate::write!(fmt, $hint, self.get()); + } + } + }; +} + +non_zero! {num::NonZeroI8, "{=i8}"} +non_zero! {num::NonZeroI16, "{=i16}"} +non_zero! {num::NonZeroI32, "{=i32}"} +non_zero! {num::NonZeroI64, "{=i64}"} +non_zero! {num::NonZeroI128, "{=i128}"} +non_zero! {num::NonZeroIsize, "{=isize}"} +non_zero! {num::NonZeroU8, "{=u8}"} +non_zero! {num::NonZeroU16, "{=u16}"} +non_zero! {num::NonZeroU32, "{=u32}"} +non_zero! {num::NonZeroU64, "{=u64}"} +non_zero! {num::NonZeroU128, "{=u128}"} +non_zero! {num::NonZeroUsize, "{=usize}"}