to_display/
to_display_impls.rs

1use std::net;
2use std::num;
3
4use crate::Context;
5use crate::ToDisplay;
6
7macro_rules! impl_to_display_primitive {
8    ($($t:ty),*) => {
9        $(
10            impl ToDisplay for $t {
11                type Displayer<'a> = &'a Self where Self: 'a;
12
13                fn display_with_context(&self, _context: Context) -> Self::Displayer<'_> {
14                    self
15                }
16            }
17        )*
18    }
19}
20
21impl_to_display_primitive!(
22    // Signed integers
23    i8,
24    i16,
25    i32,
26    i64,
27    i128,
28    isize,
29    // Unsigned integers
30    u8,
31    u16,
32    u32,
33    u64,
34    u128,
35    usize,
36    // Floating point
37    f32,
38    f64,
39    // Other primitives
40    bool,
41    char,
42    // String types
43    String,
44    &str,
45    // Network types
46    net::IpAddr,
47    net::Ipv4Addr,
48    net::Ipv6Addr,
49    net::SocketAddr,
50    net::SocketAddrV4,
51    net::SocketAddrV6,
52    // Numeric types
53    num::NonZeroI8,
54    num::NonZeroI16,
55    num::NonZeroI32,
56    num::NonZeroI64,
57    num::NonZeroI128,
58    num::NonZeroIsize,
59    num::NonZeroU8,
60    num::NonZeroU16,
61    num::NonZeroU32,
62    num::NonZeroU64,
63    num::NonZeroU128,
64    num::NonZeroUsize
65);