1pub use core::fmt::{Arguments, Debug, Error, Formatter, Result, Write};
8
9#[doc(hidden)]
15pub struct Adapter<T>(pub T);
16
17macro_rules! impl_fmt_adapter_forward {
18    ($($trait:ident),* $(,)?) => {
19        $(
20            impl<T: $trait> $trait for Adapter<T> {
21                fn fmt(&self, f: &mut Formatter<'_>) -> Result {
22                    let Self(t) = self;
23                    $trait::fmt(t, f)
24                }
25            }
26        )*
27    };
28}
29
30use core::fmt::{Binary, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex};
31impl_fmt_adapter_forward!(Debug, LowerHex, UpperHex, Octal, Binary, Pointer, LowerExp, UpperExp);
32
33pub trait Display {
41    fn fmt(&self, f: &mut Formatter<'_>) -> Result;
43}
44
45impl<T: ?Sized + Display> Display for &T {
46    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
47        Display::fmt(*self, f)
48    }
49}
50
51impl<T: ?Sized + Display> core::fmt::Display for Adapter<&T> {
52    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
53        let Self(t) = self;
54        Display::fmt(t, f)
55    }
56}
57
58macro_rules! impl_display_forward {
59    ($(
60        $( { $($generics:tt)* } )? $ty:ty $( { where $($where:tt)* } )?
61    ),* $(,)?) => {
62        $(
63            impl$($($generics)*)? Display for $ty $(where $($where)*)? {
64                fn fmt(&self, f: &mut Formatter<'_>) -> Result {
65                    core::fmt::Display::fmt(self, f)
66                }
67            }
68        )*
69    };
70}
71
72impl_display_forward!(
73    bool,
74    char,
75    core::panic::PanicInfo<'_>,
76    Arguments<'_>,
77    i128,
78    i16,
79    i32,
80    i64,
81    i8,
82    isize,
83    str,
84    u128,
85    u16,
86    u32,
87    u64,
88    u8,
89    usize,
90    {<T: ?Sized>} crate::sync::Arc<T> {where crate::sync::Arc<T>: core::fmt::Display},
91    {<T: ?Sized>} crate::sync::UniqueArc<T> {where crate::sync::UniqueArc<T>: core::fmt::Display},
92);