Function brownstone::try_build_iter [−][src]
Expand description
Build a fixed-size array from an iterator. The first N
elements of the
iterator are collected into an array of length N
. Returns None
if the
iterator doesn’t yield enough elements.
Example
let array: [i32; 5] = brownstone::try_build_iter(1..).unwrap();
assert_eq!(array, [1, 2, 3, 4, 5]);
Iterator too short
let array: Option<[i32; 10]> = brownstone::try_build_iter(1..5);
assert!(array.is_none());