Skip to content

No way to have + or * as separator token in macros #18700

Open
@bouk

Description

I'm trying to write a macro that sums a list of expressions, but it doesn't work because it's not possible to have + or * as the seperator token. For example:

macro_rules! sum {
    (
        $($e:expr)+ => (
        $($e)++ // ???
    )
}

It'll interpret is as there being no seperator token, and it seems to just stick a + at the end. Escaping the first + doesn't work either.

I'm using rust head

@bstrie

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions