Struct Sublist

Source
pub struct Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,
{ /* private fields */ }
Expand description

A sublist that maps a list of errors into a parent error type

When an object of this type is dropped, it will call the given MapFn object with a ErrorList<E> containing all the errors that were pushed into it. The map function will be used to map that error list to a single ParentErr object which will then be pushed onto the parent’s error list.

This type implements DerefMut to an ErrorList, so it can basically be thought of as an ErrorList with a fancy destructor.

Implementations§

Source§

impl<'a, E, MapFn, Parent, ParentErr> Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,

Source

pub fn new(map_fn: MapFn, parent: &'a mut Parent) -> Self

Create a new sublist that maps a list of subfunction errors to the parent error

map_fn is a function that accepts an ErrorList<E> and returns a ParentErr, which is then pushed into the parent’s error list.

It is recommended use WriteErrorList::sublist instead of this.

Methods from Deref<Target = ErrorList<E>>§

Source

pub fn is_empty(&self) -> bool

Returns whether the error list is empty

Source

pub fn len(&self) -> usize

Return the length of the error list

Source

pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a E>
where E: 'a,

Iterate the error list, returning immutable references

Source

pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut E>
where E: 'a,

Iterate the error list, returning mutable references

Trait Implementations§

Source§

impl<'a, E, MapFn, Parent, ParentErr> Deref for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,

Source§

type Target = ErrorList<E>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, E, MapFn, Parent, ParentErr> DerefMut for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, E, MapFn, Parent, ParentErr> Drop for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, E, MapFn, Parent, ParentErr> WriteErrorList<E> for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: FnOnce(ErrorList<E>) -> ParentErr, Parent: WriteErrorList<ParentErr>,

Source§

fn push(&mut self, error: E)

Add an error to the list of errors
Source§

fn subwriter<'sub, SubMapFn, SubErr: 'sub>( &'sub mut self, map_fn: SubMapFn, ) -> impl WriteErrorList<SubErr> + 'sub
where SubMapFn: FnOnce(ErrorList<SubErr>) -> E + 'sub,

Create a new mapping error writer with this as its parent Read more
Source§

fn sublist<SubMapFn, SubErr>( &mut self, map_fn: SubMapFn, ) -> Sublist<'_, SubErr, SubMapFn, Self, E>
where SubMapFn: FnOnce(ErrorList<SubErr>) -> E,

Start a new error list with this error list as its parent Read more
Source§

fn finish(self)

Finish this error list Read more

Auto Trait Implementations§

§

impl<'a, E, MapFn, Parent, ParentErr> Freeze for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: Freeze,

§

impl<'a, E, MapFn, Parent, ParentErr> RefUnwindSafe for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: RefUnwindSafe, Parent: RefUnwindSafe, E: RefUnwindSafe,

§

impl<'a, E, MapFn, Parent, ParentErr> Send for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: Send, Parent: Send, E: Send,

§

impl<'a, E, MapFn, Parent, ParentErr> Sync for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: Sync, Parent: Sync, E: Sync,

§

impl<'a, E, MapFn, Parent, ParentErr> Unpin for Sublist<'a, E, MapFn, Parent, ParentErr>
where MapFn: Unpin, E: Unpin,

§

impl<'a, E, MapFn, Parent, ParentErr> !UnwindSafe for Sublist<'a, E, MapFn, Parent, ParentErr>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.