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

Trailing comma in multiline macros #26

Open
aaronabramov opened this issue Jun 17, 2020 · 3 comments
Open

Trailing comma in multiline macros #26

aaronabramov opened this issue Jun 17, 2020 · 3 comments

Comments

@aaronabramov
Copy link
Owner

    assert_err_matches_regex!(
        conn.query_raw("SELECT 1").await,
        "time out"
    );

works, but

    assert_err_matches_regex!(
        conn.query_raw("SELECT 1").await,
        "time out",
    );

doesn't

@TheWebDevel
Copy link
Contributor

Found a Similar issue: gluon-lang/gluon#770

And it's commit to solve the issue: Marwes/gluon@bb41fa1

Using this worked for me but it required me to define multiple patterns (One with a trailing comma and one without) inside assertion macros which kinda go against the DRY principle. Let me know if you have a better approach for this. :D

@aaronabramov
Copy link
Owner Author

@TheWebDevel would something like $( , )? work?
i remember i solved before with a separate macro definition, but yeah... this whole crate is already not DRY, so it'd be nice to not 2x every macro definition 🙂

@TheWebDevel
Copy link
Contributor

$( , ) This is what worked for me but I had to define respective pattern matching to handle with and without trailing comma scenarios.

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