Trait generic_array::sequence::GenericSequence

source ·
pub unsafe trait GenericSequence<T>: Sized + IntoIterator {
    type Length: ArrayLength<T>;
    type Sequence: GenericSequence<T, Length = Self::Length> + FromIterator<T>;

    // Required method
    fn generate<F>(f: F) -> Self::Sequence
       where F: FnMut(usize) -> T;
}
Expand description

Defines some sequence with an associated length and iteration capabilities.

This is useful for passing N-length generic arrays as generics.

Required Associated Types§

source

type Length: ArrayLength<T>

GenericArray associated length

source

type Sequence: GenericSequence<T, Length = Self::Length> + FromIterator<T>

Concrete sequence type used in conjuction with reference implementations of GenericSequence

Required Methods§

source

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

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, T: 'a, S: GenericSequence<T>> GenericSequence<T> for &'a S

source§

type Length = <S as GenericSequence<T>>::Length

source§

type Sequence = <S as GenericSequence<T>>::Sequence

source§

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

source§

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

source§

type Length = <S as GenericSequence<T>>::Length

source§

type Sequence = <S as GenericSequence<T>>::Sequence

source§

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

Implementors§

source§

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