Rust Error Tutorial

Best practices for handling errors in Rust

Benjamin Kay
crash dummy

Errare humanum est, perseverare autem diabolicum. Any non-trivial program will encounter conditions that produce an error. Any program not written to anticipate these errors is diabolical. Rust makes error handling easy with the Result type, and The Rust Book does an excellent job explaining how to use it in simple examples. In this post we take a deep-dive into the bowels of Rust error handling and learn about the best practices for handling errors in more complex programs.

Fallible Iterators in Rust

resultit: A lightweight crate for iterating over Results

Benjamin Kay
robotic assembly line

Rust iterators and the associated framework of adapters/combinators are a powerful assembly line for transforming one sequence into another. The ResultIt crate provides an ergonomic way to handle iterators that can fail, i.e. iterators of Result that could countain an Error. Take, for example, the common problem of flattenning an iterator of nested results.

Nom Tutorial

Taking a bite out of Rust's parser combinator crate

Benjamin Kay
donut with bite missing

Nom is a powerful parser/combinator library written in Rust for binary and text streams. Its applications are similar to that of regular expressions, but Nom offers better performance, type safety, and error handling. This tutorial supplements the official documentation for the newly-released version 5 of the library.