pub struct PredicateMatcher<P, D1, D2> { /* private fields */ }Expand description
A matcher which applies predicate on the value.
See predicate.
Implementations§
Source§impl<P> PredicateMatcher<P, NoDescription, NoDescription>
impl<P> PredicateMatcher<P, NoDescription, NoDescription>
Sourcepub fn with_description<D1: PredicateDescription, D2: PredicateDescription>(
self,
positive_description: D1,
negative_description: D2,
) -> PredicateMatcher<P, D1, D2>
pub fn with_description<D1: PredicateDescription, D2: PredicateDescription>( self, positive_description: D1, negative_description: D2, ) -> PredicateMatcher<P, D1, D2>
Configures this instance to provide a more meaningful description.
For example, to make sure the error message is more useful
predicate(|x: i32| x % 2 == 1)
.with_description("is odd", "is even")This is optional as it only provides value when the test fails.
Description can be passed by &str, String or Fn() -> Into<String>.
Trait Implementations§
Source§impl<T: Debug + Copy, P, D1: PredicateDescription, D2: PredicateDescription> Matcher<T> for PredicateMatcher<P, D1, D2>
impl<T: Debug + Copy, P, D1: PredicateDescription, D2: PredicateDescription> Matcher<T> for PredicateMatcher<P, D1, D2>
Source§fn matches(&self, actual: T) -> MatcherResult
fn matches(&self, actual: T) -> MatcherResult
Returns whether the condition matches the datum
actual. Read moreSource§fn describe(&self, result: MatcherResult) -> Description
fn describe(&self, result: MatcherResult) -> Description
Returns a description of
self or a negative description if
matcher_result is DoesNotMatch. Read moreSource§fn explain_match(&self, actual: ActualT) -> Description
fn explain_match(&self, actual: ActualT) -> Description
Source§impl<P, D1, D2> MatcherBase for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> MatcherBase for PredicateMatcher<P, D1, D2>
Auto Trait Implementations§
impl<P, D1, D2> Freeze for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> RefUnwindSafe for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> Send for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> Sync for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> Unpin for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> UnsafeUnpin for PredicateMatcher<P, D1, D2>
impl<P, D1, D2> UnwindSafe for PredicateMatcher<P, D1, D2>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more