Trait TryRetain

Source
pub trait TryRetain<T> {
    // Required method
    fn try_retain<E, F>(&mut self, _: F) -> Result<(), E>
       where F: FnMut(&T) -> Result<bool, E>;
}

Required Methods§

Source

fn try_retain<E, F>(&mut self, _: F) -> Result<(), E>
where F: FnMut(&T) -> Result<bool, E>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> TryRetain<T> for Vec<T>

Source§

fn try_retain<E, F>(&mut self, f: F) -> Result<(), E>
where F: FnMut(&T) -> Result<bool, E>,

Filters vector elements in-place by applying a predicate function that can return an error.

Evaluates each element using the provided function, retaining or removing elements based on the returned boolean value when successful; if the function returns an error for an element, the error is recorded and the element is retained, with the final result reflecting any encountered error.

Implementors§