aaronabramov / k9

Rust testing library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trailing comma in multiline macros

aaronabramov opened this issue · comments

    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

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

@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 🙂

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