Rust needs evert(), which turns an iterator over Result of T into a Result of a collection of T or a collection of errors
currently the most ergonomic way to do this is to wrap a whole pipeline in a function boundary and use `?`.
So it turns a Vec<Result, Error> into Result<Vec<T>, Error>, and you can turn it into Vec<T> simply with ?. Otherwise you would probably need a for loop.
I think she is talking about this functionality which already exists. It is not very intuitive though.
let res = my_collection .iter() .map(|x| method_that_returns_result(x)) .collect::<Result<Vec<T>, Error>>()?;
So it turns a
Vec<Result, Error>
intoResult<Vec<T>, Error>
, and you can turn it intoVec<T
> simply with?
. Otherwise you would probably need a for loop.do you mean
Vec<Result<T, Error>>
? why would an error type be the second type argument for aVec
?