Macro acick_util::matches [−][src]
macro_rules! matches {
($expression : expr => $pattern : pat) => { ... };
}
Expand description
Check if an expression matches a refutable pattern.
Syntax: matches!(
expression =>
pattern )
Return a boolean, true if the expression matches the pattern, false otherwise.
Examples
#[macro_use]
extern crate acick_util;
pub enum Foo<T> {
A,
B(T),
}
impl<T> Foo<T> {
pub fn is_a(&self) -> bool {
matches!(*self => Foo::A)
}
pub fn is_b(&self) -> bool {
matches!(*self => Foo::B(_))
}
}