Trait GenericSequence
pub unsafe trait GenericSequence<T>: Sized + IntoIterator {
type Length: ArrayLength;
type Sequence: GenericSequence<T, Length = Self::Length> + FromIterator<T>;
// Required method
fn generate<F>(f: F) -> Self::Sequence
where F: FnMut(usize) -> T;
// Provided method
fn repeat(value: T) -> Self::Sequence
where T: Clone { ... }
}Expand description
Defines some sequence with an associated length and iteration capabilities.
This is useful for passing N-length generic arrays as generics.
§Safety
Care must be taken when implementing such that methods are safe.
Lengths must match, and element drop on panic must be handled.
Source
GenericArray associated length
Source
Owned sequence type used in conjunction with reference implementations of GenericSequence
Source
Initializes a new sequence instance using the given function.
If the generator function panics while initializing the sequence, any already initialized elements will be dropped.
See also FallibleGenericSequence::try_generate.
Source
Initializes a new sequence instance by repeating the given value.
This will only clone the value Length - 1 times, taking ownership for the last element.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.