Module rust_examples::errors [−][src]
Expand description
This module presents several possibilities of how to handle errors in Rust.
In general, there are two kinds of errors:
- Recoverable errors - those are contexts in which there is a possibility to react and correct the situation (e.g. by substituing default value or calling error handler)
- Unrecoverable errors - these are unexpected situations which cannot be handled by an application or library resulting in a crash of the program
Naturally, Rust promotes types like Option and Result to mitigate the amount of possible non-recoverable situations.
Functions
This version of division is somewhat artificial but demonstrates another error context, the Result.
This function computes num / d in a naive way that causes the program to panic if d = 0
