-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap interpolated variables to forward Pointer correctly
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use core::fmt::{ | ||
self, Binary, Debug, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex, | ||
}; | ||
|
||
pub struct Var<'a, T: ?Sized>(pub &'a T); | ||
|
||
/// Pointer is the only one for which there is a difference in behavior between | ||
/// `Var<'a, T>` vs `&'a T`. | ||
impl<'a, T: Pointer + ?Sized> Pointer for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
Pointer::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: Binary + ?Sized> Binary for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
Binary::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: Debug + ?Sized> Debug for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
Debug::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: Display + ?Sized> Display for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
Display::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: LowerExp + ?Sized> LowerExp for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
LowerExp::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: LowerHex + ?Sized> LowerHex for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
LowerHex::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: Octal + ?Sized> Octal for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
Octal::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: UpperExp + ?Sized> UpperExp for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
UpperExp::fmt(self.0, formatter) | ||
} | ||
} | ||
|
||
impl<'a, T: UpperHex + ?Sized> UpperHex for Var<'a, T> { | ||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
UpperHex::fmt(self.0, formatter) | ||
} | ||
} |