Function predicates::ord::eq

source ·
pub fn eq<T>(constant: T) -> EqPredicate<T>
where T: Debug + PartialEq,
Expand description

Creates a new predicate that will return true when the given variable is equal to a pre-defined value.

§Examples

use predicates::prelude::*;

let predicate_fn = predicate::eq(5);
assert_eq!(true, predicate_fn.eval(&5));
assert_eq!(false, predicate_fn.eval(&10));

let predicate_fn = predicate::eq("Hello");
assert_eq!(true, predicate_fn.eval("Hello"));
assert_eq!(false, predicate_fn.eval("Goodbye"));

let predicate_fn = predicate::eq(String::from("Hello"));
assert_eq!(true, predicate_fn.eval("Hello"));
assert_eq!(false, predicate_fn.eval("Goodbye"));