Macro mac::matches [] [src]

macro_rules! matches {
    ($expr:expr, $($pat:tt)+) => { ... };
}

Returns true if an expression matches a pattern.

Example


assert!(matches!(2, 1 | 2 | 3));
assert!(matches!('x', 'a' ... 'z'));
assert!(!matches!(Some(1), None));
assert!(matches!(Some(42), Some(n) if n == 42));