in gazebo/src/ext/vec.rs [21:35]
fn collect_result<T, E>(mut it: impl ExactSizeIterator<Item = Result<T, E>>) -> Result<Vec<T>, E> {
match it.next() {
None => Ok(Vec::new()),
Some(Err(e)) => Err(e),
Some(Ok(x)) => {
// +1 for the element we have already consumed
let mut res = Vec::with_capacity(it.len() + 1);
res.push(x);
for x in it {
res.push(x?);
}
Ok(res)
}
}
}