1pub use core::fmt::{
8 Arguments,
9 Debug,
10 Error,
11 Formatter,
12 Result,
13 Write, };
15
16#[doc(hidden)]
22pub struct Adapter<T>(pub T);
23
24macro_rules! impl_fmt_adapter_forward {
25 ($($trait:ident),* $(,)?) => {
26 $(
27 impl<T: $trait> $trait for Adapter<T> {
28 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
29 let Self(t) = self;
30 $trait::fmt(t, f)
31 }
32 }
33 )*
34 };
35}
36
37use core::fmt::{
38 Binary,
39 LowerExp,
40 LowerHex,
41 Octal,
42 Pointer,
43 UpperExp,
44 UpperHex, };
46impl_fmt_adapter_forward!(Debug, LowerHex, UpperHex, Octal, Binary, Pointer, LowerExp, UpperExp);
47
48pub trait Display {
56 fn fmt(&self, f: &mut Formatter<'_>) -> Result;
58}
59
60impl<T: ?Sized + Display> Display for &T {
61 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
62 Display::fmt(*self, f)
63 }
64}
65
66impl<T: ?Sized + Display> core::fmt::Display for Adapter<&T> {
67 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
68 let Self(t) = self;
69 Display::fmt(t, f)
70 }
71}
72
73macro_rules! impl_display_forward {
74 ($(
75 $( { $($generics:tt)* } )? $ty:ty $( { where $($where:tt)* } )?
76 ),* $(,)?) => {
77 $(
78 impl$($($generics)*)? Display for $ty $(where $($where)*)? {
79 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
80 core::fmt::Display::fmt(self, f)
81 }
82 }
83 )*
84 };
85}
86
87impl_display_forward!(
88 bool,
89 char,
90 core::panic::PanicInfo<'_>,
91 Arguments<'_>,
92 i128,
93 i16,
94 i32,
95 i64,
96 i8,
97 isize,
98 str,
99 u128,
100 u16,
101 u32,
102 u64,
103 u8,
104 usize,
105 {<T: ?Sized>} crate::sync::Arc<T> {where crate::sync::Arc<T>: core::fmt::Display},
106 {<T: ?Sized>} crate::sync::UniqueArc<T> {where crate::sync::UniqueArc<T>: core::fmt::Display},
107);