pub unsafe trait FallibleGenericSequence<T>: GenericSequence<T>where
Self::Sequence: FromFallibleIterator<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§
Sourcefn try_generate<F, E>(f: F) -> Result<Self::Sequence, E>
fn try_generate<F, E>(f: F) -> Result<Self::Sequence, 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.