pub trait FromIterator<A>: Sized {
    fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
fn try_from_iter<T: IntoIterator<Item = A>>(
        iter: T
    ) -> Result<Self, FromIteratorError>;
fn from_iter_exact<T: IntoIterator<Item = A>>(iter: T) -> Self;
fn try_from_iter_exact<T: IntoIterator<Item = A>>(
        iter: T
    ) -> Result<Self, FromIteratorExactError<A>>; }
Expand description

This trait contains the from_iter and try_from_iter methods.

Example:

use from_iter::FromIterator;

let iter = (0..).map(|i| i * 2);
let array = <[i32; 8]>::from_iter(iter);
assert_eq!(array, [0, 2, 4, 6, 8, 10, 12, 14]);

Required methods

This method fills an array using the given iterator. Note that it will panic if the iterator doesn’t contain enough items.

This method fills an array using the given iterator. If there aren’t enough items available, it will return a FromIteratorError.

This method fills an array using the given iterator. Note that it will panic if the iterator doesn’t contain enough items, or there are more elements than expected.

This method fills an array using the given iterator.

Implementations on Foreign Types

Implementors