# [−][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

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)

You can look for items with an exact name by putting double quotes around your request: `"string"`

Look for items inside another one by searching for a path: `vec::Vec`