Module percolate::predicate[][src]

Expand description

MutPredicates are RefProjections towards bool.
MutPredicates are MutProjections towards bool.

Prefer using Into Predicate types over Projection types in your function signatures to make them more intuitively readable.

Example

Predicates 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

alias: FusedRefProjectionMut<T, bool>

IntoFusedPredicateMut

alias: IntoFusedRefProjectionMut<T, bool, X>

IntoPredicateMut

alias: IntoRefProjectionMut<T, bool, X>

PredicateMut

alias: RefProjectionMut<T, bool>

Functions

from_blocking_mut

alias: projection::from_ref_blocking_mut(…)

Type Definitions

FusedBlockingMut

alias: projection::FusedRefBlockingMut