Function googletest::matchers::predicate
source · pub fn predicate<P>(
predicate: P,
) -> PredicateMatcher<P, NoDescription, NoDescription>
Expand description
Creates a matcher based on the predicate provided.
verify_that!(3, predicate(|x: i32| x % 2 == 1))?; // Passes
The predicate should take the subject type and return a boolean.
Note: even if the Rust compiler should be able to infer the type of the closure argument, it is likely that it won’t. See https://github.com/rust-lang/rust/issues/12679 for update on this issue. This is easily fixed by explicitly declaring the type of the argument