How to break iteration and return an error if Iterator::map returns Result::Err?
Hello, colleagues! I'm new to Rust and encountered a problem when working with iterators and error handling. I have a vector of strings that need to be parsed into numbers. I'm using `Iterator::map` with `str::parse::()`, which returns `Result`. If parsing fails, I want to immediately stop iteration and return an error from the function, rather than continuing to process the remaining elements.
Here's what I'm trying:
```rust
use std::num::ParseIntError;
fn parse_numbers(input: &[&str]) -> Result, ParseIntError> {
input.iter()
.map(|s| s.parse::())
.collect()
}
```
This code works, but it collects all results into `Result, ParseIntError>`. If one string fails to parse, the error is still returned, but I suspect that `collect