std::matches - Rust
Description: API documentation for the Rust `matches` macro in crate `std`.
Keywords: rust, rustlang, rust-lang, matches

# [−][src]Macro std::matches

    macro_rules! matches {
        ($ expression : expr, $ ($ pattern : pat) | + $ (if $ guard : expr) ?) => { ... };
    }

🔬 This is a nightly-only experimental API. (`matches_macro` #65721)

Returns whether the given expression matches any of the given patterns.

Like in a `match` expression, the pattern can be optionally followed by `if` and a guard expression that has access to names bound by the pattern.

# Examples

    #![feature(matches_macro)]

    let foo = 'f';
    assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));

    let bar = Some(4);
    assert!(matches!(bar, Some(x) if x > 2));Run