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 new() -> MultiErrors<E>
pub fn new() -> MultiErrors<E>
Create an empty error collection.
Sourcepub fn ok(self) -> Result<(), MultiErrors<E>>
pub fn ok(self) -> Result<(), MultiErrors<E>>
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 for MultiErrors<E>where
E: Clone,
impl<E> Clone for MultiErrors<E>where
E: Clone,
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 for MultiErrors<E>where
E: Debug,
impl<E> Debug for MultiErrors<E>where
E: Debug,
Source§impl<E> Default for MultiErrors<E>
impl<E> Default for MultiErrors<E>
Source§fn default() -> MultiErrors<E>
fn default() -> MultiErrors<E>
Source§impl<'de, E> Deserialize<'de> for MultiErrors<E>where
E: Deserialize<'de>,
impl<'de, E> Deserialize<'de> for MultiErrors<E>where
E: Deserialize<'de>,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<MultiErrors<E>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<MultiErrors<E>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<E> Display for MultiErrors<E>where
E: Display,
impl<E> Display for MultiErrors<E>where
E: Display,
Source§impl<E> Error for MultiErrors<E>where
E: Error + 'static,
impl<E> Error for MultiErrors<E>where
E: Error + 'static,
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§fn from(errors: Vec<E>) -> MultiErrors<E>
fn from(errors: Vec<E>) -> MultiErrors<E>
Source§impl<E> IntoIterator for MultiErrors<E>
impl<E> IntoIterator for MultiErrors<E>
Source§impl<E> Serialize for MultiErrors<E>where
E: Serialize,
impl<E> Serialize for MultiErrors<E>where
E: Serialize,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl<E> Forget for MultiErrors<E>
impl<E> Freeze for MultiErrors<E>
impl<E> Move for MultiErrors<E>
impl<E> RefUnwindSafe for MultiErrors<E>where
Vec<E>: RefUnwindSafe,
impl<E> Send for MultiErrors<E>
impl<E> Sync for MultiErrors<E>
impl<E> Unpin for MultiErrors<E>
impl<E> UnsafeUnpin for MultiErrors<E>where
Vec<E>: UnsafeUnpin,
impl<E> UnwindSafe for MultiErrors<E>where
Vec<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
impl<T> CacheValue for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> ErrorExt for T
impl<T> ErrorExt for T
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<I> IntoStreamingIterator for Iwhere
I: IntoIterator,
impl<I> IntoStreamingIterator for Iwhere
I: IntoIterator,
Source§fn into_streaming_iter(self) -> Convert<Self::IntoIter>
fn into_streaming_iter(self) -> Convert<Self::IntoIter>
Source§fn into_streaming_iter_ref<'a, T>(self) -> ConvertRef<'a, Self::IntoIter, T>
fn into_streaming_iter_ref<'a, T>(self) -> ConvertRef<'a, Self::IntoIter, T>
Source§fn into_streaming_iter_mut<'a, T>(self) -> ConvertMut<'a, Self::IntoIter, T>
fn into_streaming_iter_mut<'a, T>(self) -> ConvertMut<'a, Self::IntoIter, T>
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,
impl<T> PtyHandle for Twhere
T: Send,
impl<T> Read<Exclusive, BecauseExclusive> 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