mirror of
https://github.com/Noratrieb/mono-fmt.git
synced 2026-01-17 08:45:05 +01:00
better cfg
This commit is contained in:
parent
98025d204f
commit
5a6f2e5130
1 changed files with 14 additions and 21 deletions
35
src/args.rs
35
src/args.rs
|
|
@ -48,15 +48,8 @@ impl Arguments for Str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! not_for_pointer {
|
|
||||||
(Pointer $($tt:tt)*) => {};
|
|
||||||
($_not_pointer:ident $($tt:tt)*) => {
|
|
||||||
$($tt)*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! traits {
|
macro_rules! traits {
|
||||||
($(struct $name:ident: trait $trait:ident);* $(;)?) => {
|
($($(#[$no_reference_blanket_impl:ident])? struct $name:ident: trait $trait:ident);* $(;)?) => {
|
||||||
$(
|
$(
|
||||||
pub struct $name<T, O>(pub T, pub O);
|
pub struct $name<T, O>(pub T, pub O);
|
||||||
|
|
||||||
|
|
@ -74,21 +67,20 @@ macro_rules! traits {
|
||||||
)*
|
)*
|
||||||
|
|
||||||
$(
|
$(
|
||||||
not_for_pointer! {
|
$( #[cfg(all(any(), $no_reference_blanket_impl))] )?
|
||||||
$trait
|
impl<T: $trait + ?Sized> $trait for &T {
|
||||||
|
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
|
||||||
impl<T: $trait + ?Sized> $trait for &T {
|
<T as $trait>::fmt(&self, f)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$( #[cfg(all(any(), $no_reference_blanket_impl))] )?
|
||||||
|
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 mod macro_exports {
|
||||||
|
|
@ -110,5 +102,6 @@ traits!(
|
||||||
struct UpperHexArg: trait UpperHex;
|
struct UpperHexArg: trait UpperHex;
|
||||||
struct UpperExpArg: trait UpperExp;
|
struct UpperExpArg: trait UpperExp;
|
||||||
struct LowerExpArg: trait LowerExp;
|
struct LowerExpArg: trait LowerExp;
|
||||||
|
#[no_reference_blanket_impl]
|
||||||
struct PointerArg: trait Pointer;
|
struct PointerArg: trait Pointer;
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue