Skip to content

| with the pat macro fragment specifier #4581

Closed
@SimonSapin

Description

@SimonSapin

Hi,

I made this macro:

macro_rules! is_match(
    ($value:expr, $pattern:pat) => (
        match $value { $pattern => true, _ => false }
    );
)

… which is pretty useful for constructs like if is_match!(next_char(), '0'..'9').
However this does not work with macro "alternatives": if is_match!(next_char(), 'a'..'z' | 'A'..'Z')

error: No rules expected the token: |

Is there a reason this couldn’t work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions