0

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?

laktak
  • 57,064
  • 17
  • 134
  • 164

1 Answers1

0

@aspex thanks for you help, it's

let fold: io::Result<Vec<_>> = iter.collect();
laktak
  • 57,064
  • 17
  • 134
  • 164