Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macro_rules! expand {
- (
- $(#[cb $attr:meta])*
- $(#[$attr:meta])*
- pub fn foo() {}
- ) => (
- expand_attrs! {
- [ $($attr),* ]
- $(#[$attr])*
- pub fn foo() {}
- }
- );
- }
- macro_rules! expand_attrs {
- (
- [ ]
- $($rest:tt)*
- ) => ($($rest)*);
- (
- [
- foo
- $($rest:meta)*
- ]
- $($body:tt)*
- ) => (
- expand_attrs! {
- [ $($rest)* ]
- $($body)*
- }
- )
- (
- [
- bar($a:meta)
- $($rest:meta)*
- ]
- $($body:tt)*
- ) => (
- expand_attrs! {
- [ $($rest)* ]
- $($body)*
- }
- )
- }
- expand! {
- #[foo]
- #[bar(a)]
- pub fn foo() {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement