generics2 0.3.3

Provides macros for parsing generics (with optional where clause) in `macro_rules!` - enhanced fork of generics.
Documentation
  • Coverage
  • 75%
    3 out of 4 items documented2 out of 2 items with examples
  • Size
  • Source code size: 51.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.64 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • lyphyser/generics2
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lyphyser

generics2

Provides macros for parsing generics and where clauses in macro_rules!.

pub trait TheTrait { }

#[doc(hidden)]
pub use generics2::parse as generics_parse;
#[doc(hidden)]
pub use std::compile_error as std_compile_error;

#[macro_export]
macro_rules! impl_the_trait {
    (
        $name:ident $($token:tt)*
    ) => {
        $crate::generics_parse! {
            $crate::impl_the_trait {
                @impl $name
            }
            $($token)*
        }
    };
    (
        @impl $name:ident [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
    ) => {
        impl $($g)* $crate::TheTrait for $name $($r)* $($w)* { }
    };
    (
        @impl $name:ident [$($g:tt)*] [$($r:tt)*] [$($w:tt)*] $($token:tt)+ 
    ) => {
        $crate::std_compile_error!(
            "invalid input, allowed input is '$name $( < $generics > $(where $where_clause)? )?'"
        );
    };
}