mirror of
https://github.com/Noratrieb/mono-fmt.git
synced 2026-01-16 08:15:04 +01:00
more impls
This commit is contained in:
parent
8862186a1f
commit
98025d204f
4 changed files with 72 additions and 49 deletions
25
src/args.rs
25
src/args.rs
|
|
@ -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),*};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue