Skip to main content

Matcher

Trait Matcher 

Source
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§

Source

fn matches(&self, actual: &T) -> bool

Returns whether the provided value matches.

Provided Methods§

Source

fn required_matches(&self, actual: Option<&T>) -> bool

Returns whether the provided value is set and matches.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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.

Source§

fn matches(&self, actual: &T) -> bool

Source§

fn required_matches(&self, actual: Option<&T>) -> bool

Implementors§