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§

type Length: ArrayLength<T>

GenericArray associated length

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

Concrete sequence type used in conjuction with reference implementations of GenericSequence

Required Methods§

fn generate<F>(f: F) -> Self::Sequencewhere 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.

Implementations on Foreign Types§

§

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

§

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

§

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

§

fn generate<F>(f: F) -> <&'a mut S as GenericSequence<T>>::Sequencewhere F: FnMut(usize) -> T,

§

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

§

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

§

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

§

fn generate<F>(f: F) -> <&'a S as GenericSequence<T>>::Sequencewhere F: FnMut(usize) -> T,

Implementors§

§

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

§

type Length = N

§

type Sequence = GenericArray<T, N>