ResultExt

Trait ResultExt 

Source
pub trait ResultExt {
    type Output;

    // Required methods
    fn unwrap_or_default_log(self) -> Self::Output;
    fn unwrap_or_else_log(
        self,
        f: impl FnOnce() -> Self::Output,
    ) -> Self::Output;
    fn unwrap_or_log(self, default: Self::Output) -> Self::Output;
}
Expand description

Extension trait providing tracing alternatives to Result unwrap methods.

Required Associated Types§

Source

type Output

The type of the “successful” output, intended to be T for a Result<T, E>.

Required Methods§

Source

fn unwrap_or_default_log(self) -> Self::Output

Returns the contained Ok value, or logs at the warn level and returns a default value.

Source

fn unwrap_or_else_log(self, f: impl FnOnce() -> Self::Output) -> Self::Output

Returns the contained Ok value, or logs at the warn level and computes a default value from a closure.

Source

fn unwrap_or_log(self, default: Self::Output) -> Self::Output

Returns the contained Ok value, or logs at the warn level and returns the provided default.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Default, E: Debug> ResultExt for Result<T, E>

Source§

type Output = T

Source§

fn unwrap_or_default_log(self) -> T

Source§

fn unwrap_or_else_log(self, f: impl FnOnce() -> T) -> T

Source§

fn unwrap_or_log(self, default: T) -> T

Implementors§