I have an Iterator<Item=io::Result<u8>>
that I'd like to convert to io::Result<Vec<u8>>
.
iter.map(|x| x.unwrap()).collect::<Vec<u8>>()
will give me the Vec<u8>
but how can I keep the Err
part in case of an error?
@aspex thanks for you help, it's
let fold: io::Result<Vec<_>> = iter.collect();