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

Allow trailing punctuation in macros #1219

Merged
merged 1 commit into from
Apr 7, 2023
Merged

Conversation

ModProg
Copy link
Contributor

@ModProg ModProg commented Mar 9, 2023

When splitting e.g. fields over multiple lines it is quite common to add a
trailing comma in the last line in rust code.

This pr makes it so that this is allowed now:

vector![
    some_longer_expression() + something,
    some_longer_expression() + something_else,
    some_longer_expression() + another_thing,
    some_longer_expression() + 42,
];

I also added a test verifying that this was already the case with matrix!.

@ModProg
Copy link
Contributor Author

ModProg commented Mar 9, 2023

on another note, what was the rational to use a proc macro, AFAICT these macros look very doable in macro_rules, or was it just for ease of writing them (e.g. allowing easy reusing of code).

Edit: well they would require quite a bit of redundant code as declarative macros.

@sebcrozet sebcrozet merged commit f5af5db into dimforge:dev Apr 7, 2023
12 checks passed
@sebcrozet
Copy link
Member

Thanks! Yeah, using proc-macro makes the code simpler overall.

@ModProg ModProg deleted the trailing_punct branch April 7, 2023 17:38
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

Successfully merging this pull request may close these issues.

None yet

2 participants