Errors as Values

No exceptions, no null: failure is data you are forced to look at.

Rust has no exceptions and no null. Absence is Option<T> and failure is Result<T, E>. The ? operator hands back the value on success and returns early on error, so the unhappy path stays explicit without burying the code in branches. Edit the input and run it both ways.

check your understanding

A function returns `Result<Vec<f64>, ParseError>`. Why `Result` rather than `Option<Vec<f64>>`?

Inside a function returning `Result<i32, E>`, what does the expression `s.parse::<i32>()?` do on failure?

ask the tutor about this
learners marked this complete
unlocks