Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many macros could declare closures rather than just functions #19

Closed
eternaleye opened this issue Mar 15, 2015 · 1 comment
Closed

Many macros could declare closures rather than just functions #19

eternaleye opened this issue Mar 15, 2015 · 1 comment

Comments

@eternaleye
Copy link

As a quick example, a rewritten alt!()

#[macro_export]
macro_rules! alt (
    ($name:ident<$i:ty,$o:ty>, $($rest:tt)*) => (
        fn $name(i:$i) -> IResult<$i,$o>{
            alt_parser!(i | $($rest)*)
        }
    );
    ($($rest:tt)*) => ( | i | { alt_parser!(i | $($rest)*) } );
);

Just one additional line, and now omitting the name allows it to be used in value position.

@Geal
Copy link
Collaborator

Geal commented Mar 24, 2015

Since alt! now returns a block, this is no longer needed

@Geal Geal closed this as completed Mar 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants