Macro faux::from_fn [−][src]
macro_rules! from_fn { ($matcher:expr) => { ... }; }
Returns an ArgMatcher
that succeeds if the provided closure
returns true
.
The returned Argmatcher
implements fmt::Display
using the
string representation of the closure, so it is only recommended
for use with simple closures. For complex argument matching,
implement your own ArgMatcher
to make the expectation message
more specific and less verbose.
use faux::{from_fn, matcher::ArgMatcher}; let contains_hello = from_fn!(|message: &str| message.contains("hello")); assert!(contains_hello.matches("hello world")); assert!(!contains_hello.matches("bye world")); println!("{}", contains_hello); // '|message: &str| message.contains("hello")'