pub struct MultiErrors<E = Error> { /* private fields */ }Expand description
A collection of errors that enables continuing work while collecting failures.
This type implements the “error parameter” pattern: instead of short-circuiting on the first error, processing continues and errors are accumulated. The caller can inspect the collection afterward to determine whether all operations succeeded.
§Ergonomic Result handling
collect_result lets you process a Result<T, E>
while keeping the happy path dominant:
use vtcode_commons::MultiErrors;
let mut errors: MultiErrors<String> = MultiErrors::new();
let value: Option<i32> = errors.collect_result("42".parse::<i32>().map_err(|e| e.to_string()));
assert_eq!(value, Some(42));§Composing with traditional error handling
Use ok or to_anyhow to convert
back into a traditional Result.
Implementations§
Source§impl<E> MultiErrors<E>
impl<E> MultiErrors<E>
Sourcepub fn extend(&mut self, iter: impl IntoIterator<Item = E>)
pub fn extend(&mut self, iter: impl IntoIterator<Item = E>)
Extend the collection with multiple errors.
Sourcepub fn into_inner(self) -> Vec<E>
pub fn into_inner(self) -> Vec<E>
Consume the collector and return the underlying error vector.
Sourcepub fn ok(self) -> Result<(), Self>
pub fn ok(self) -> Result<(), Self>
Convert into Result<()> — succeeds if no errors were collected.
Sourcepub fn collect_result<T, F>(&mut self, result: Result<T, F>) -> Option<T>where
F: Into<E>,
pub fn collect_result<T, F>(&mut self, result: Result<T, F>) -> Option<T>where
F: Into<E>,
Process a Result, returning the success value or collecting the error.
This is the key ergonomic method — it keeps the happy path as the primary flow while silently collecting errors for later inspection.
Sourcepub fn to_anyhow(&self) -> Errorwhere
E: Display,
pub fn to_anyhow(&self) -> Errorwhere
E: Display,
Convert into an anyhow::Error for use with traditional error handling.
Trait Implementations§
Source§impl<E: Clone> Clone for MultiErrors<E>
impl<E: Clone> Clone for MultiErrors<E>
Source§fn clone(&self) -> MultiErrors<E>
fn clone(&self) -> MultiErrors<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E: Debug> Debug for MultiErrors<E>
impl<E: Debug> Debug for MultiErrors<E>
Source§impl<E> Default for MultiErrors<E>
impl<E> Default for MultiErrors<E>
Source§impl<'de, E: Deserialize<'de>> Deserialize<'de> for MultiErrors<E>
impl<'de, E: Deserialize<'de>> Deserialize<'de> for MultiErrors<E>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<E: Display> Display for MultiErrors<E>
impl<E: Display> Display for MultiErrors<E>
Source§impl<E: Error + 'static> Error for MultiErrors<E>
impl<E: Error + 'static> Error for MultiErrors<E>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E> From<Vec<E>> for MultiErrors<E>
impl<E> From<Vec<E>> for MultiErrors<E>
Source§impl<E> IntoIterator for MultiErrors<E>
impl<E> IntoIterator for MultiErrors<E>
Auto Trait Implementations§
impl<E> Freeze for MultiErrors<E>
impl<E> RefUnwindSafe for MultiErrors<E>where
E: RefUnwindSafe,
impl<E> Send for MultiErrors<E>where
E: Send,
impl<E> Sync for MultiErrors<E>where
E: Sync,
impl<E> Unpin for MultiErrors<E>where
E: Unpin,
impl<E> UnsafeUnpin for MultiErrors<E>
impl<E> UnwindSafe for MultiErrors<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, C> CompactStringExt for C
impl<I, C> CompactStringExt for C
Source§fn concat_compact(self) -> CompactString
fn concat_compact(self) -> CompactString
CompactString Read moreSource§fn join_compact<S>(self, separator: S) -> CompactString
fn join_compact<S>(self, separator: S) -> CompactString
CompactString Read moreimpl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more