FallibleGenericSequence

Trait FallibleGenericSequence 

Source
pub unsafe trait FallibleGenericSequence<T>: GenericSequence<T>{
    // Required method
    fn try_generate<F, E>(f: F) -> Result<Self::Sequence, E>
       where F: FnMut(usize) -> Result<T, E>;
}
Expand description

Extension to GenericSequence for fallible initialization.

§Safety

Care must be taken when implementing such that methods are safe.

Lengths must match, and element drop on panic or error must be handled.

Required Methods§

Source

fn try_generate<F, E>(f: F) -> Result<Self::Sequence, E>
where F: FnMut(usize) -> Result<T, E>,

Initializes a new sequence instance using the given fallible function.

If the generator function returns an error or panics while initializing the sequence, any already initialized elements will be dropped and the error returned.

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<'a, T: 'a, S: FallibleGenericSequence<T>> FallibleGenericSequence<T> for &'a S

Source§

fn try_generate<F, E>(f: F) -> Result<Self::Sequence, E>
where F: FnMut(usize) -> Result<T, E>,

Source§

impl<'a, T: 'a, S: FallibleGenericSequence<T>> FallibleGenericSequence<T> for &'a mut S

Source§

fn try_generate<F, E>(f: F) -> Result<Self::Sequence, E>
where F: FnMut(usize) -> Result<T, E>,

Implementors§

Source§

impl<T, N: ArrayLength> FallibleGenericSequence<T> for GenericArray<T, N>
where Self: IntoIterator<Item = T>,