Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T> {
    // Required methods
    fn display_err(self, ctx: &OutputContext) -> Result<T, ()>;
    fn display_and_exit(self, ctx: &OutputContext, exit_code: i32) -> T;
}
Expand description

Extension trait for Result types to display errors.

Required Methods§

Source

fn display_err(self, ctx: &OutputContext) -> Result<T, ()>

Display the error if present using the given output context.

Source

fn display_and_exit(self, ctx: &OutputContext, exit_code: i32) -> T

Display the error if present and exit with the given code.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E: Error> ResultExt<T> for Result<T, E>

Source§

fn display_err(self, ctx: &OutputContext) -> Result<T, ()>

Source§

fn display_and_exit(self, ctx: &OutputContext, exit_code: i32) -> T

Implementors§