diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/deserializer/mod.rs | 20 | ||||
| -rw-r--r-- | src/util.rs | 29 | 
2 files changed, 31 insertions, 18 deletions
| diff --git a/src/deserializer/mod.rs b/src/deserializer/mod.rs index 6a512dc..6d7d277 100644 --- a/src/deserializer/mod.rs +++ b/src/deserializer/mod.rs @@ -68,23 +68,11 @@ pub trait Deserializer      fn skip_to_tag_end(&mut self, tag_name: &str) -> Result<(), Error<Infallible>>;  } -macro_rules! maybe_static_doc { -    () => { -        "Bound to `'static` if the `deserializer-static-generics` feature is enabled." -    }; -} - -#[cfg(any(not(feature = "deserializer-static-generics"), doc))] -trait_alias! { -    #[doc = maybe_static_doc!()] -    pub MaybeStatic; -} - -#[cfg(all(feature = "deserializer-static-generics", not(doc)))] -trait_alias! { -    #[doc = maybe_static_doc!()] +trait_alias!( +    bounds_when_feature = "deserializer-static-generics", +    /// Bound to `'static` if the `deserializer-static-generics` feature is enabled.      pub MaybeStatic: 'static; -} +);  /// Whether or not to skip the end tag of a tagged element.  /// diff --git a/src/util.rs b/src/util.rs index 5c9ffb8..d96c4f4 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,13 +1,38 @@  macro_rules! trait_alias {      (          $(#[$attr: meta])* -        $visibility: vis $name: ident$(<$($type_param: ident),*>)?$(: $first_bound: tt $(+ $bound: tt)*)?; +        $visibility: vis $name: ident$(<$($type_param: ident),*>)? +            $(: $first_bound: tt $(+ $bound: tt)*)?;      ) => {          $(#[$attr])*          $visibility trait $name $(<$($type_param),*>)? $(: $first_bound $(+ $bound)*)? {} -        impl<T: $($first_bound $(+ $bound)*)?, $($($type_param),*)?> $name$(<$($type_param),*>)? for T {} +        impl< +            T: $($first_bound $(+ $bound)*)?, +            $($($type_param),*)? +        > $name$(<$($type_param),*>)? for T {}      }; + +    // Rule where the trait bounds will only be applied if the specified feature is enabled +    ( +        bounds_when_feature = $bounds_feature: literal, +        $(#[$attr: meta])* +        $visibility: vis $name: ident$(<$($type_param: ident),*>)? +            $(: $first_bound: tt $(+ $bound: tt)*)?; +    ) => { +        #[cfg(feature = $bounds_feature)] +        trait_alias! { +            $(#[$attr])* +            $visibility $name$(<$($type_param),*>)? +                $(: $first_bound $(+ $bound)*)?; +        } + +        #[cfg(not(feature = $bounds_feature))] +        trait_alias! { +            $(#[$attr])* +            $visibility $name$(<$($type_param),*>)?; +        } +    }  }  macro_rules! feature_alternate { | 
