pub fn any_of<T>(matchers: Vec<Box<dyn BehaveMatch<T>>>) -> AnyOf<T>Expand description
Creates a matcher that passes when at least one inner matcher passes.
An empty list fails, matching the semantics of Iterator::any on an
empty iterator.
ยงExamples
use behave::prelude::*;
use behave::combinators::any_of;
struct IsZero;
impl BehaveMatch<i32> for IsZero {
fn matches(&self, actual: &i32) -> bool { *actual == 0 }
fn description(&self) -> &str { "to be zero" }
}
struct IsNegative;
impl BehaveMatch<i32> for IsNegative {
fn matches(&self, actual: &i32) -> bool { *actual < 0 }
fn description(&self) -> &str { "to be negative" }
}
let matcher = any_of(vec![
Box::new(IsZero) as Box<dyn BehaveMatch<i32>>,
Box::new(IsNegative),
]);
let result = Expectation::new(-3, "-3").to_match(matcher);
assert!(result.is_ok());