Skip to main content

filter_effect

Function filter_effect 

Source
pub fn filter_effect<T, Env, F, Eff>(
    items: Vec<T>,
    predicate: F,
) -> BoxedEffect<Vec<T>, AnalysisError, Env>
where T: Send + Clone + 'static, Env: Clone + Send + Sync + 'static, F: Fn(&T) -> Eff + Send + Sync + 'static, Eff: Effect<Output = bool, Error = AnalysisError, Env = Env> + Send + 'static,
Expand description

Filter a collection using an effectful predicate.

This combinator evaluates a predicate effect for each item and keeps only those for which the predicate returns true.

§Arguments

  • items - The collection to filter
  • predicate - A function that produces an effect returning bool

§Returns

An effect that produces a vector of items that passed the predicate.

§Example

let paths = vec!["a.rs", "b.rs", "missing.rs"];
let effect = filter_effect(paths, |p| file_exists_effect(p.into()));
let existing = effect.run(&env).await?; // Only existing files