How do I stop iteration and return an error when Iterator::map returns a Result::Err?
Result implements FromIterator, so you can move the Result outside and iterators will take care of the rest (including stopping iteration if an error is found). #[derive(Debug)] struct Item; type Id = String; fn find(id: &Id) -> Result<Item, String> { Err(format!(“Not found: {:?}”, id)) } fn main() { let s = |s: &str| s.to_string(); let … Read more