Trait iter_fixed::FromIteratorFixed[][src]

pub trait FromIteratorFixed<I: Iterator, const N: usize> {
    fn from_iter_fixed(iter_fixed: IteratorFixed<I, N>) -> Self;
}
Expand description

Conversion from an IteratorFixed.

By implementing FromIteratorFixed for a type, you define how it will be created from an iterator of fixed size.

FromIteratorFixed::from_iter_fixed() is rarely called explicitly, and is instead used through IteratorFixed::collect() method. See IteratorFixed::collect()’s documentation for more examples.

See also: crate::IntoIteratorFixed.

Required methods

fn from_iter_fixed(iter_fixed: IteratorFixed<I, N>) -> Self[src]

Creates a value from a fixed size iterator.

Basic usage:

use iter_fixed::{IntoIteratorFixed, FromIteratorFixed};

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

let a = <[i32; 3]>::from_iter_fixed(two_four_six);
assert_eq!(a, [2, 4, 6]);

Using IteratorFixed::collect() to implicitly use FromIteratorFixed:

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]);

Implementors

impl<I: Iterator, const N: usize> FromIteratorFixed<I, N> for [<I as Iterator>::Item; N][src]

fn from_iter_fixed(iter_fixed: IteratorFixed<I, N>) -> Self[src]

Creates an array from a fixed size iterator.

Basic usage:

use iter_fixed::{IntoIteratorFixed, FromIteratorFixed};

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

let a = <[i32; 3]>::from_iter_fixed(two_four_six);
assert_eq!(a, [2, 4, 6]);

Using IteratorFixed::collect() to implicitly use FromIteratorFixed:

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]);