|
1 | | -use core::fmt::{ |
2 | | - self, Binary, Debug, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex, |
3 | | -}; |
| 1 | +use core::fmt::{self, Pointer}; |
4 | 2 |
|
5 | 3 | pub struct Var<'a, T: ?Sized>(pub &'a T); |
6 | 4 |
|
7 | | -/// Pointer is the only one for which there is a difference in behavior between |
8 | | -/// `Var<'a, T>` vs `&'a T`. |
9 | 5 | impl<'a, T: Pointer + ?Sized> Pointer for Var<'a, T> { |
10 | 6 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
11 | 7 | Pointer::fmt(self.0, formatter) |
12 | 8 | } |
13 | 9 | } |
14 | | - |
15 | | -impl<'a, T: Binary + ?Sized> Binary for Var<'a, T> { |
16 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
17 | | - Binary::fmt(self.0, formatter) |
18 | | - } |
19 | | -} |
20 | | - |
21 | | -impl<'a, T: Debug + ?Sized> Debug for Var<'a, T> { |
22 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
23 | | - Debug::fmt(self.0, formatter) |
24 | | - } |
25 | | -} |
26 | | - |
27 | | -impl<'a, T: Display + ?Sized> Display for Var<'a, T> { |
28 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
29 | | - Display::fmt(self.0, formatter) |
30 | | - } |
31 | | -} |
32 | | - |
33 | | -impl<'a, T: LowerExp + ?Sized> LowerExp for Var<'a, T> { |
34 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
35 | | - LowerExp::fmt(self.0, formatter) |
36 | | - } |
37 | | -} |
38 | | - |
39 | | -impl<'a, T: LowerHex + ?Sized> LowerHex for Var<'a, T> { |
40 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
41 | | - LowerHex::fmt(self.0, formatter) |
42 | | - } |
43 | | -} |
44 | | - |
45 | | -impl<'a, T: Octal + ?Sized> Octal for Var<'a, T> { |
46 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
47 | | - Octal::fmt(self.0, formatter) |
48 | | - } |
49 | | -} |
50 | | - |
51 | | -impl<'a, T: UpperExp + ?Sized> UpperExp for Var<'a, T> { |
52 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
53 | | - UpperExp::fmt(self.0, formatter) |
54 | | - } |
55 | | -} |
56 | | - |
57 | | -impl<'a, T: UpperHex + ?Sized> UpperHex for Var<'a, T> { |
58 | | - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
59 | | - UpperHex::fmt(self.0, formatter) |
60 | | - } |
61 | | -} |
0 commit comments