error-concept
Partial failures: preserve each item outcome
When records are independent, keep successful results and failed record identifiers instead of throwing away the whole batch. State whether a partially successful result is acceptable to callers. Expected stdout (not executed): good=[(0, 3), (2, 8)]; failed=[1] Expected stderr: (empty) Expected exit: success Common mistake: Silently discarding failures using filter_map(Result::ok).
Formal Syntax & Structure
rust syntaxrust
Vec<(usize, Result<T, E>)>Working Example
Example Snippetrust
fn main() { let mut good = Vec::new(); let mut bad = Vec::new(); for (i, input) in ["3", "bad", "8"].iter().enumerate() { match input.parse::<u32>() { Ok(value) => good.push((i, value)), Err(_) => bad.push(i), } } println!("good={good:?}; failed={bad:?}");}