pub trait Matcher<T> {
// Required method
fn matches(&self, actual: &T) -> bool;
// Provided method
fn required_matches(&self, actual: Option<&T>) -> bool { ... }
}
Expand description
Common pattern to define a matcher for a metadata input T
.
Used in matching engines like filtering and routing rules.
Required Methods§
Provided Methods§
Sourcefn required_matches(&self, actual: Option<&T>) -> bool
fn required_matches(&self, actual: Option<&T>) -> bool
Returns whether the provided value is set and matches.
Implementations on Foreign Types§
Source§impl<T, O> Matcher<T> for Option<O>where
O: Matcher<T>,
impl<T, O> Matcher<T> for Option<O>where
O: Matcher<T>,
Implement Matcher
for optional matchers, so that if a matcher is left
unspecified, it matches all inputs by default.