[−][src]Function array_init::from_iter
pub fn from_iter<Array, Iterable>(iterable: Iterable) -> Option<Array> where
Iterable: IntoIterator<Item = Array::Item>,
Array: IsArray,
Initialize an array given an iterator
We will iterate until the array is full or the iterator is exhausted. Returns
None
if the iterator is exhausted before we can fill the array.
- Once the array is full, extra elements from the iterator (if any) won't be consumed.
Examples
// Initialize an array from an iterator // producing an array of [1,2,3,4] repeated let four = [1,2,3,4]; let mut iter = four.iter().copied().cycle(); let arr: [u32; 50] = array_init::from_iter(iter).unwrap();