Rs
Module 6Robust ErrorsLesson 3 of 820 min

Result Combinators & ?

map, and_then, and multi-step parsers.

Combinators

rust
parse(s).map(|x| x * 2.0)
parse(s).and_then(safe_ln)

? sequences

Parse num, parse den, reject zero, return ratio.

Challenge

Parse "S,K,T" into a tuple with ?.

Tips
  • and_then flattens
  • map keeps Err
  • ? early-returns

Try it live

Result Combinators & ?Rust 2021
Loading editor…
Output
Press Run to compile and execute.