pub trait FromFallibleIterator<T>: Sized {
// Required method
fn from_fallible_iter<I, E>(iter: I) -> Result<Self, E>
where I: IntoIterator<Item = Result<T, E>>;
}Expand description
Extension to FromIterator for fallible initialization.
Required Methods§
Sourcefn from_fallible_iter<I, E>(iter: I) -> Result<Self, E>where
I: IntoIterator<Item = Result<T, E>>,
fn from_fallible_iter<I, E>(iter: I) -> Result<Self, E>where
I: IntoIterator<Item = Result<T, E>>,
Initializes a new collection from a fallible iterator.
If the iterator returns an error or panics while initializing the sequence, any already initialized elements will be dropped and the error returned.
Unlike .collect::<Result<Self, E>>(), which short-circuits the source iterator
on the first error before the collection’s FromIterator impl can verify the
correct number of elements — causing a length-mismatch panic — this method
handles the error and length check correctly.
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<T, N: ArrayLength> FromFallibleIterator<T> for Box<GenericArray<T, N>>
Available on crate feature alloc only.
impl<T, N: ArrayLength> FromFallibleIterator<T> for Box<GenericArray<T, N>>
Available on crate feature
alloc only.