26 releases
0.5.3 | Feb 28, 2024 |
---|---|
0.5.1 | Oct 30, 2023 |
0.4.4 | May 24, 2022 |
0.3.2 | Jul 31, 2021 |
0.2.6 | Nov 3, 2020 |
#213 in Rust patterns
1,690 downloads per month
Used in 8 crates
(4 directly)
48KB
1.5K
SLoC
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)? )?'"
);
};
}