ErrorCollector

Trait ErrorCollector 

Source
pub trait ErrorCollector<E> {
    type Collection;

    // Required methods
    fn empty() -> Self;
    fn push_err(&mut self, err: E) -> ControlFlow;
    fn with_value<T>(self, val: T) -> Result<T, Self::Collection>;
}
Expand description

Determines the manner in which the encountered error(s) are processed, stored and returned, as well as whether the iteration should continue or not.

Required Associated Types§

Source

type Collection

The type to be returned after the iteration has been stopped

Required Methods§

Source

fn empty() -> Self

Creates an empty ErrorCollector.

Source

fn push_err(&mut self, err: E) -> ControlFlow

Processes an error. Returns an ControlFlow type indicating whether the iteration shall stop or not.

Source

fn with_value<T>(self, val: T) -> Result<T, Self::Collection>

Returns Ok(val) if the iteration run to completion, or an error collection of type Self::Collection if error(s) were encountered.

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<E, F: From<E>> ErrorCollector<E> for Option<F>

Source§

type Collection = F

Source§

fn empty() -> Self

Source§

fn push_err(&mut self, err: E) -> ControlFlow

Source§

fn with_value<T>(self, val: T) -> Result<T, Self::Collection>

Source§

impl<E, F: From<E>> ErrorCollector<E> for Vec<F>

Source§

type Collection = Vec<F>

Source§

fn empty() -> Self

Source§

fn push_err(&mut self, err: E) -> ControlFlow

Source§

fn with_value<T>(self, val: T) -> Result<T, Self::Collection>

Implementors§