Trait errata::FallibleExt

source ·
pub trait FallibleExt<T> {
    // Required method
    fn fail(self, msg: impl Display) -> T;
}
Expand description

The trait providing fail. Implemented for Option<T> and Result<T, E: Display>.

Required Methods§

source

fn fail(self, msg: impl Display) -> T

Exits the program cleanly, calling destructors and printing an error message.

If you enable feature color, prints in bold red.

Usage:

let bad: Option<i32> = None;

// Prints the text verbatim to stderr, then exits with code 1.
bad.fail("Expected bad to contain a value");

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> FallibleExt<T> for Option<T>

source§

fn fail(self, msg: impl Display) -> T

source§

impl<T, E: Display> FallibleExt<T> for Result<T, E>

source§

fn fail(self, msg: impl Display) -> T

Implementors§