vecfold: Fold vectors of Results into Result of vector
This package provide a generic way to "unwrap" a Vec<Result<T,E>>
into
Result<Vec<&T>, &E>
. Here is an example:
let valid: = "1,2,3".split.map.collect;
let invalid: = "1,2,a".split.map.collect;
// happy path, no errors, just the values
assert_eq!;
// sad path returns the error
assert!;
If you need to collect all errors you can use .foldr_bisect
. It converts
Vec<Result<T, E>>
, to (Vec<&T>, Vec<&E>)
.
// happy path, no errors, return empty error vector
assert_eq!;
// sad path, populate error vector
let = invalid.foldr_bisect;
assert_eq!;