Function faux::matcher::eq_against [−][src]
pub fn eq_against<Arg>(
expected: impl PartialEq<Arg> + Debug
) -> impl ArgMatcher<Arg> where
Arg: ?Sized,
Returns an equality matcher for different types.
Unlike eq
, it matches even if the types are different. This,
however, comes at the cost of not being able to match across
borrows.
use faux::matcher::{self, ArgMatcher}; // `String` implements `PartialEq<&str>` assert!(matcher::eq_against("x".to_string()).matches(&"x")); assert!(!matcher::eq_against("x".to_string()).matches(&"y"));