如何将iterator
Result
转换为Result
向量?
作为一个例子,假设我想转换从Bytes
特征可获得的Read
迭代器:
use std::io::{Read, Result};
use std::fs::File;
fn main() {
let f = File::open("some-file").unwrap();
let bytes = f.bytes();
let byte_vector: Result<Vec<u8>> = read_bytes(bytes);
}
fn read_bytes<I: Iterator<Item=Result<u8>>>(bytes: I) -> Result<Vec<u8>> {
unimplemented!();
}