Module percolate::predicate [−][src]
Expand description
Mut
Predicate
s are RefProjection
s towards bool
.
MutPredicate
s are MutProjection
s towards bool
.
Prefer using Into
Predicate
types over Projection
types in your function signatures to make them more intuitively readable.
Example
Predicate
s are useful for all sorts of async combinators, like filtering a Future:
use core::{future::Future, pin::Pin}; use ergo_pin::ergo_pin; use percolate::predicate::{IntoPredicateMut, PredicateMut}; #[ergo_pin] async fn filter_future<T, X>( source: impl Future<Output = T>, predicate: impl IntoPredicateMut<T, X>, ) -> Option<T> { let item = source.await; pin!(predicate.into_predicate_mut()) .test(&item) .await .then(move || item) }
Traits
FusedPredicateMut | |
IntoFusedPredicateMut | |
IntoPredicateMut | |
PredicateMut | alias: |
Functions
from_blocking_mut |
Type Definitions
FusedBlockingMut |