more impls

This commit is contained in:
nora 2022-09-24 22:20:53 +02:00
parent 8862186a1f
commit 98025d204f
4 changed files with 72 additions and 49 deletions

View file

@ -48,6 +48,13 @@ impl Arguments for Str {
}
}
macro_rules! not_for_pointer {
(Pointer $($tt:tt)*) => {};
($_not_pointer:ident $($tt:tt)*) => {
$($tt)*
}
}
macro_rules! traits {
($(struct $name:ident: trait $trait:ident);* $(;)?) => {
$(
@ -66,6 +73,24 @@ macro_rules! traits {
}
)*
$(
not_for_pointer! {
$trait
impl<T: $trait + ?Sized> $trait for &T {
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
<T as $trait>::fmt(&self, f)
}
}
impl<T: $trait + ?Sized> $trait for &mut T {
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
<T as $trait>::fmt(&self, f)
}
}
}
)*
pub mod macro_exports {
pub use super::{$($name, $trait),*};
}