I want to collect a lazy iterator with expensive operations and arbitrary length into a fixed-length array without wasting resources on redundant (remaining) elements. I've tried this but it doesn't compile:
let my_array = my_vec
.map(expensive_operation) // only maximum of 3 calls should be allowed
.collect::<Result<[String; 3], _>>() // returns Ok(_) if my_vec.len() ≥ 3
.expect("insufficient number of elements");