Trait OrExit

Source
pub trait OrExit<R, S>
where S: AsRef<str>,
{ // Required method fn or_exit(self, message: S, code: i32) -> R; }
Expand description

Types implementing the OrExit provide the or_exit function that can be used to exit a program when a computation was not successful.

The goal of this thread is to provide a function similar to unwrap() without a panic.

Required Methods§

Source

fn or_exit(self, message: S, code: i32) -> R

Exit the program with the given message and status code if the computation is not successful. Otherwise, unwrap the value and return it.

Implementations on Foreign Types§

Source§

impl<R, S> OrExit<R, S> for Option<R>
where S: AsRef<str>,

Source§

fn or_exit(self, description: S, code: i32) -> R

Source§

impl<R, S, E> OrExit<R, S> for Result<R, E>
where S: AsRef<str>, E: Display,

Source§

fn or_exit(self, description: S, code: i32) -> R

Implementors§