Handling errors is always an interesting challenge in every programming language. There are many styles available: returning numeric values, exceptions (software interrupts), result and option types, and so on. Each way requires different architectures and has implications for performance, readability, and maintainability. Rust's approach is—just like many functional programming languages—based on integrating failure as part of the regular workflow. This means that whatever the return value, an error is not a special case but integrated into the handling. Option and Result are the central types that allow for returning results as well as errors. panic! is an additional macro to halt the thread immediately in case it cannot/should not continue.
In this chapter, we'll cover some basic recipes and architectures to use Rust...