Trait iter_fixed::IntoIteratorFixed[][src]

pub unsafe trait IntoIteratorFixed<const N: usize> {
    type Item;
    type IntoIter: Iterator<Item = Self::Item>;
    fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>;
}
Expand description

Conversion into an IteratorFixed.

By implementing IntoIteratorFixed for a type, you define how it will be converted to an iterator of fixed size.

See also: crate::FromIteratorFixed.

Safety

Implementer has to guarantee that the inner iterator will always yield exactly N elements

Associated Types

type Item[src]

The type of the elements being iterated over.

type IntoIter: Iterator<Item = Self::Item>[src]

What will be the underlaying iterator for the IteratorFixed that we are turning this into?

Required methods

fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>[src]

Creates a fixed size iterator from a value.

Basic usage:

use iter_fixed::IntoIteratorFixed;

let two_four_six = [1, 2, 3].into_iter_fixed().map(|x| 2 * x);

let a: [i32; 3] = two_four_six.collect();
assert_eq!(a, [2, 4, 6]);

Implementations on Foreign Types

impl<T: Clone, const N: usize> IntoIteratorFixed<N> for Repeat<T>[src]

fn into_iter_fixed(self) -> IteratorFixed<Take<Repeat<T>>, N>[src]

Creates a fixed size iterator from an core::iter::Repeat

Basic usage:

use core::iter;
use iter_fixed::IntoIteratorFixed;

let one_one_one = iter::repeat(1).into_iter_fixed();

let a: [i32; 3] = one_one_one.collect();
assert_eq!(a, [1, 1, 1]);

type Item = T

type IntoIter = Take<Repeat<T>>

Implementors

impl<'a, T, const N: usize> IntoIteratorFixed<N> for &'a [T; N][src]

fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>[src]

Creates a fixed size iterator from a borrowed array.

Basic usage:

use iter_fixed::IntoIteratorFixed;

let two_four_six = [1, 2, 3].into_iter_fixed().map(|x| 2 * x);

let a: [i32; 3] = two_four_six.collect();
assert_eq!(a, [2, 4, 6]);

type Item = &'a T

type IntoIter = Iter<'a, T>

impl<I: Iterator, const N: usize> IntoIteratorFixed<N> for IteratorFixed<I, N> where
    IteratorFixed<I, N>: IntoIterator
[src]

fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>[src]

IteratorFixed implements IntoIteratorFixed as a no op. This allows passing an IteratorFixed where an IntoIteratorFixed was expected

Basic usage with zip which expects an IntoIteratorFixed as its argument:

use iter_fixed::IntoIteratorFixed;
let one_one = [1, 1].into_iter_fixed();
let zipped: [_; 2] = [1, 2].into_iter_fixed().zip(one_one).collect();

assert_eq!(zipped, [(1, 1), (2, 1)]);

type Item = I::Item

type IntoIter = I

impl<T, const N: usize> IntoIteratorFixed<N> for [T; N][src]

fn into_iter_fixed(self) -> IteratorFixed<IntoIter<T, N>, N>[src]

Creates a fixed size iterator from an array.

Basic usage:

use iter_fixed::IntoIteratorFixed;

let two_four_six = [1, 2, 3].into_iter_fixed().map(|x| 2 * x);

let a: [i32; 3] = two_four_six.collect();
assert_eq!(a, [2, 4, 6]);

type Item = T

type IntoIter = IntoIter<T, N>