Slug: iter-from-01 · Paired reading: Chapters 9 and 8
Prompt
Implement fn parse_all(lines: &[&str]) -> Result<Vec<i32>, String> that parses
each line with str::parse::<i32>(), collecting into Result<Vec<i32>, String>.
On the first failure, return Err with that line’s text (owned).
Contract
- Empty input →
Ok(vec![]) - Stop at first bad token (do not keep parsing)
- Success preserves order
Predict first
Why does collect into Result<Vec<_>, _> short-circuit?
Rust angle
FromIterator for Result is the idiomatic fallible pipeline — Chapter 8 meets Chapter 9.