Hello everyone,
i am trying to iterate over two different types of iterators, but i couldn't find a way to do it
async fn _from_file(&self, file: &String) -> Result<()> {
let file = File::open(file)?;
let reader = BufReader::new(file);
self._run(reader.lines()).await
}
async fn _from_set(&self, set: HashSet<Result<String>>) -> Result<()> {
self._run(set.iter()).await
}
async fn _run<I: Iterator<Item = Result<String>>>(&self, iter: I) -> Result<()> {
let futs = FuturesUnordered::new();
for path in iter {
println!("{:?}", path);
}
Ok(())
}
the Result type is defined in lib.rs like this
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
The error i am getting
49 | self._run(reader.lines()).await
| ^^^^ expected struct `std::io::Error`, found struct `std::boxed::Box`
53 | self._run(set.iter()).await
| ^^^^ expected reference, found enum `std::result::Result`