Hello,
In some code, I like to unzip
from an iterator of Result
of tuple
.
But it's seem than unzip don't handle it, unlike collect.
I want to convert an
Iterator<Item = Result<(A,B), _>
into a
Result<(Vec<A>, Vec<B>), _>
Example :
fn main() {
let vec = vec![Ok(('a',3)), Ok(('b',6)), Ok(('i',1)), Err("bad".into())]
let res: Result<(Vec<_>, Vec<_>),_> = vec.iter().unzip();
let (_chars, _num) = res.unwrap();
}
Do you think it would be possible to update unzip
in sush a way than it can handle Result like collect
, or to implement a try_unzip
?
Or do you know an alternative ?
Thank you