1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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}"}

impl Format for num::TryFromIntError {
    fn format(&self, fmt: Formatter) {
        crate::write!(fmt, "TryFromIntError(())");
    }
}