generics

Crates.iogenerics
lib.rsgenerics
version0.5.3
sourcesrc
created_at2020-09-18 10:36:37.380174
updated_at2024-02-28 05:39:51.504295
descriptionProvides macros for parsing generics (with optional where clause) in `macro_rules!`.
homepage
repositoryhttps://github.com/A1-Triard/generics
max_upload_size
id290061
size49,391
Warlock (A1-Triard)

documentation

https://docs.rs/generics/

README

maintenance: actively developed

generics-parse

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

pub trait TheTrait { }

#[doc(hidden)]
pub use generics::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)? )?'"
        );
    };
}
Commit count: 57

cargo fmt