Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt<E> {
    type Ok;

    // Required methods
    fn log_err(self) -> Option<Self::Ok>;
    fn log_err_with_backtrace(self) -> Option<Self::Ok>
       where E: Debug;
    fn debug_assert_ok(self, reason: &str) -> Self;
    fn warn_on_err(self) -> Option<Self::Ok>;
    fn log_with_level(self, level: Level) -> Option<Self::Ok>;
    fn anyhow(self) -> Result<Self::Ok, Error>
       where E: Into<Error>;
}

Required Associated Types§

Required Methods§

Source

fn log_err(self) -> Option<Self::Ok>

Source

fn log_err_with_backtrace(self) -> Option<Self::Ok>
where E: Debug,

Like ResultExt::log_err, but uses {:?} formatting so anyhow::Error values emit their full backtrace. Reach for this only when a backtrace is genuinely wanted — most call sites should stick with log_err / warn_on_err, whose output is a single chained error message.

Source

fn debug_assert_ok(self, reason: &str) -> Self

Assert that this result should never be an error in development or tests.

Source

fn warn_on_err(self) -> Option<Self::Ok>

Source

fn log_with_level(self, level: Level) -> Option<Self::Ok>

Source

fn anyhow(self) -> Result<Self::Ok, Error>
where E: Into<Error>,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, E> ResultExt<E> for Result<T, E>
where E: Display,

Source§

type Ok = T

Source§

fn log_err(self) -> Option<T>

Source§

fn log_err_with_backtrace(self) -> Option<T>
where E: Debug,

Source§

fn debug_assert_ok(self, reason: &str) -> Result<T, E>

Source§

fn warn_on_err(self) -> Option<T>

Source§

fn log_with_level(self, level: Level) -> Option<T>

Source§

fn anyhow(self) -> Result<T, Error>
where E: Into<Error>,

Implementors§