Function predicates::predicate::contains_hashable [] [src]

pub fn contains_hashable<I, T>(iter: I) -> HashableContainsPredicate<T> where
    T: Hash + Eq,
    I: IntoIterator<Item = T>, 

Creates a new predicate that will return true when the given variable is contained with the set of items provided.

Note that this implementation requires Item to be Hash + Eq. The ContainsPredicate uses a less efficient search algorithm but only requires Item implement PartialEq. The implementation-specific predicates will be deprecated when Rust supports trait specialization.

Examples

use predicates::predicate::*;

let predicate_fn = contains_hashable(vec![1, 3, 5]);
assert_eq!(true, predicate_fn.eval(&1));
assert_eq!(false, predicate_fn.eval(&2));
assert_eq!(true, predicate_fn.eval(&3));
assert_eq!(false, predicate_fn.eval(&4));
assert_eq!(true, predicate_fn.eval(&5));