mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-23 15:14:35 +02:00
A few of the early exercises had much larger estimates than were actually necessary for the super simple early exercises. I've gone through and reviewed the time estimates for exercises and tweaked the estimates based on how much time students have actually needed in my classes so far.
602 B
602 B
minutes |
---|
30 |
Exercise: Rewriting with Result
The following implements a very simple parser for an expression language.
However, it handles errors by panicking. Rewrite it to instead use idiomatic
error handling and propagate errors to a return from main
. Feel free to use
thiserror
and anyhow
.
HINT: start by fixing error handling in the parse
function. Once that is
working correctly, update Tokenizer
to implement
Iterator<Item=Result<Token, TokenizerError>>
and handle that in the parser.
{{#include exercise.rs:types}}
{{#include exercise.rs:panics}}