pub trait IterCollectArray: Iterator {
    // Provided method
    fn collect_array<const N: usize>(self) -> [Self::Item; N]
       where Self: Sized { ... }
}
Available on crate feature collect_array only.
Expand description

An extension trait that provides the collect_array method for iterators.

Provided Methods§

source

fn collect_array<const N: usize>(self) -> [Self::Item; N]
where Self: Sized,

Consumes the entire iterator collecting it into an array.

Panics

If the iterator contains too little or too many elements to fit in the array.

Examples

Basic usage:

use itermore::IterCollectArray;

let mut iter = "a,b,c".split(",");

let arr: [_; 3] = iter.collect_array();
assert_eq!(arr, ["a", "b", "c"]);

Implementors§

source§

impl<I> IterCollectArray for I
where I: Iterator + ?Sized,