How do I convert a Vec to Result? [duplicate]

An iterator over Result<T, E> can be collect()-ed directly into a Result<Vec<T>, E>; that is, your entire function can be replaced with:

let new: Result<Vec<T>, E> = v.into_iter().collect()

Leave a Comment