Function rust_examples::errors::maybe_div[][src]

pub fn maybe_div(num: i32, d: i32) -> Option<i32>
Expand description

This version of division models the error case (d = 0) by an Option.

An option is a context in which a value might be present (Some variant) or missing (None variant). Rust std library’s API implements an Option as a Monad.

Note that std already contians i32::checked_div which does the same thing as this function.