Macro generics::parse [−][src]
macro_rules! parse { ($callback : path { $($callback_args : tt) * } < $($token : tt) *) => { ... }; ($callback : path { $($callback_args : tt) * } $($token : tt) *) => { ... }; }
Expand description
Parses (optional) generics and (optional) subsequent where clause.
This macro accepts an input in the following form:
ⓘ
$callback_macro { $($callback_macro_args)* } $( < $generics > $( $tokens_between_generics_and_where_clause )* $( where $where_clause )? )? $( $( ; | { $($body)* } ) $($remaining_tokens)* )?
and expands into
ⓘ
$callback_macro! { $( $callback_macro_args )* [ $( < $generics > )? ] [ $( < $generics_without_constraints > )? ] [ $( where $where_clause )? ] $($( $tokens_between_generics_and_where_clause )*)? $( $( ; | { $($body)* } ) $($remaining_tokens)* )? }
Examples
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)? )?'" ); }; }