const_panic/fmt_impls/
nonzero_impls.rs1use crate::{FmtArg, PanicVal};
2
3use core::num::{
4 NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
5 NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
6};
7
8macro_rules! nonzero_impls {
9 ($(($int_ctor:ident, $ty:ty))*) => (
10 $(
11 primitive_static_panicfmt!{
12 fn[](&self: $ty, fmtarg) {
13 PanicVal::$int_ctor(self.0.get(), fmtarg)
14 }
15 }
16 )*
17
18 impl_for_option!{
19 $((for[], 'static, $ty, $ty))*
20 }
21 )
22}
23
24nonzero_impls! {
25 (from_u8, NonZeroU8)
26 (from_i8, NonZeroI8)
27 (from_u16, NonZeroU16)
28 (from_i16, NonZeroI16)
29 (from_u32, NonZeroU32)
30 (from_i32, NonZeroI32)
31 (from_u64, NonZeroU64)
32 (from_i64, NonZeroI64)
33 (from_u128, NonZeroU128)
34 (from_i128, NonZeroI128)
35 (from_usize, NonZeroUsize)
36 (from_isize, NonZeroIsize)
37}