pub struct ErrorCollector<E> { /* private fields */ }
Expand description
A collection of errors that can be accumulated and returned as a single result
Implementations§
Source§impl<E> ErrorCollector<E>
impl<E> ErrorCollector<E>
Sourcepub fn with(self, error: E) -> Self
pub fn with(self, error: E) -> Self
Add an error to the collection and return self for chaining
Sourcepub fn into_result<T>(self, ok_value: T) -> Result<T, Self>
pub fn into_result<T>(self, ok_value: T) -> Result<T, Self>
Return a result that is Ok if there are no errors, or Err with the collector otherwise
Sourcepub fn result<T>(&self, ok_value: T) -> Result<T, &Self>
pub fn result<T>(&self, ok_value: T) -> Result<T, &Self>
Return a result that is Ok if there are no errors, or Err with the collector otherwise
Sourcepub fn into_errors(self) -> Vec<E>
pub fn into_errors(self) -> Vec<E>
Consume the collector and return the vector of errors
Sourcepub fn errors_mut(&mut self) -> &mut Vec<E>
pub fn errors_mut(&mut self) -> &mut Vec<E>
Get a mutable reference to the vector of errors
Sourcepub fn extend(&mut self, other: ErrorCollector<E>)
pub fn extend(&mut self, other: ErrorCollector<E>)
Add all errors from another collector
Sourcepub fn try_collect<F, T>(&mut self, op: F) -> Option<T>
pub fn try_collect<F, T>(&mut self, op: F) -> Option<T>
Try an operation that may return an error, collecting the error if it occurs
Source§impl<E: ForgeError> ErrorCollector<E>
impl<E: ForgeError> ErrorCollector<E>
Trait Implementations§
Source§impl<E: Debug> Debug for ErrorCollector<E>
impl<E: Debug> Debug for ErrorCollector<E>
Source§impl<E: Default> Default for ErrorCollector<E>
impl<E: Default> Default for ErrorCollector<E>
Source§fn default() -> ErrorCollector<E>
fn default() -> ErrorCollector<E>
Returns the “default value” for a type. Read more
Source§impl<E: Display> Display for ErrorCollector<E>
impl<E: Display> Display for ErrorCollector<E>
Source§impl<E: Error> Error for ErrorCollector<E>
impl<E: Error> Error for ErrorCollector<E>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl<E> Freeze for ErrorCollector<E>
impl<E> RefUnwindSafe for ErrorCollector<E>where
E: RefUnwindSafe,
impl<E> Send for ErrorCollector<E>where
E: Send,
impl<E> Sync for ErrorCollector<E>where
E: Sync,
impl<E> Unpin for ErrorCollector<E>where
E: Unpin,
impl<E> UnwindSafe for ErrorCollector<E>where
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more