Skip to content

Suggestion: assert pattern macro. #24429

Closed
@norcalli

Description

@norcalli
macro_rules! assert_pattern {
    ($a:expr => $b:pat) => {
        assert!(match $a { $b => true, _ => false });
    }
}

Something like this would be useful for checking a pattern instead of deriving Eq,PartialEq for an enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions