pub trait MatcherBase {
// Provided methods
fn and<Right>(self, right: Right) -> ConjunctionMatcher<Self, Right>
where Self: Sized { ... }
fn or<Right>(self, right: Right) -> DisjunctionMatcher<Self, Right>
where Self: Sized { ... }
}Expand description
Base trait for matchers. Any type implementing Matcher must implement
MatcherBase, but that should be done through the #[derive(MatcherBase)]
macro.
Provided Methods§
Sourcefn and<Right>(self, right: Right) -> ConjunctionMatcher<Self, Right>where
Self: Sized,
fn and<Right>(self, right: Right) -> ConjunctionMatcher<Self, Right>where
Self: Sized,
Constructs a matcher that matches both self and right.
verify_that!("A string", starts_with("A").and(ends_with("string")))?; // Passes
verify_that!("A string", starts_with("Another").and(ends_with("string")))?; // Fails
verify_that!("A string", starts_with("A").and(ends_with("non-string")))?; // FailsSourcefn or<Right>(self, right: Right) -> DisjunctionMatcher<Self, Right>where
Self: Sized,
fn or<Right>(self, right: Right) -> DisjunctionMatcher<Self, Right>where
Self: Sized,
Constructs a matcher that matches when at least one of self or right
matches the input.
verify_that!(10, eq(2).or(ge(5)))?; // Passes
verify_that!(10, eq(2).or(eq(5)).or(ge(9)))?; // Passes
verify_that!(10, eq(2).or(ge(15)))?; // Fails