Trait predicates::prelude::PredicateBoxExt [−][src]
pub trait PredicateBoxExt<Item: ?Sized> where
Self: Predicate<Item>, { fn boxed(self) -> BoxPredicate<Item>
where
Self: Sized + Send + Sync + 'static, { ... } }
Predicate
extension for boxing a Predicate
.
Provided methods
fn boxed(self) -> BoxPredicate<Item> where
Self: Sized + Send + Sync + 'static,
[src]
Self: Sized + Send + Sync + 'static,
Returns a BoxPredicate
wrapper around this Predicate
type.
Returns a BoxPredicate
wrapper around this Predicate type. The
BoxPredicate` type has a number of useful properties:
- It stores the inner predicate as a trait object, so the type of
BoxPredicate
will always be the same even if steps are added or removed from the predicate. - It is a common type, allowing it to be stored in vectors or other collection types.
- It implements
Debug
andDisplay
.
Examples
use predicates::prelude::*; let predicates = vec![ predicate::always().boxed(), predicate::never().boxed(), ]; assert_eq!(true, predicates[0].eval(&4)); assert_eq!(false, predicates[1].eval(&4));
Implementors
impl<P, Item> PredicateBoxExt<Item> for P where
P: Predicate<Item>,
[src]
impl<P, Item> PredicateBoxExt<Item> for P where
P: Predicate<Item>,
[src]