I've been playing around with a new project that uses a lot of collections of results, for example Vec<Result<()>>
and asked some folks on Rust if they new a good way of transforming this into a Result<Vec<()>>
.
Turns out, .collect()
can do it for you!
use ;
// Err(Error { repr: Custom(Custom
// { kind: Other, error: StringError("I\'m an error!")
// }) })
// Ok([0, 1, 2])
Isn't that handy! I hope this is useful to your in your projects! Playpen Link