[][src]Trait die::Die

pub trait Die<T> {
    fn die(self, msg: &str) -> T;
fn die_code(self, msg: &str, exit_code: i32) -> T; }

Required methods

fn die(self, msg: &str) -> T

Unwraps a result/option, yielding the content of an Ok or Some.

Exits

Calls process::exit(1) if the value is an Err/None, after printing the passed message to stderr.

Examples

Basic usage:

use die::Die;
let x: Result<u32, &str> = Err("emergency failure");
x.die("strange error"); // prints `strange error` to stderr then exits with code 1

fn die_code(self, msg: &str, exit_code: i32) -> T

Unwraps a result/option, yielding the content of an Ok or Some.

Exits

Calls process::exit(exit_code) if the value is an Err/None, after printing the passed message to stderr.

Examples

Basic usage:

use die::Die;
let x: Result<u32, &str> = Err("emergency failure");
x.die_code("strange error", 3); // prints `strange error` to stderr then exits with code 3
Loading content...

Implementations on Foreign Types

impl<T, E> Die<T> for Result<T, E>[src]

impl<T> Die<T> for Option<T>[src]

Loading content...

Implementors

Loading content...