Skip to main content

FmtExpect

Trait FmtExpect 

Source
pub trait FmtExpect<T> {
    // Required method
    fn expect_fmt(self, panic: impl FnOnce() -> !) -> T;
}
Expand description

Use the unwrap_fmt! macro instead.

The only reason this exists is because Option and Result have a different number of arguments for unwrap_or_else so it’s not possible to use the same macro for both.

If you for whatever reason want your custom type to be unwrappable with this macro, then go ahead and implement this trait, I guess.

Required Methods§

Source

fn expect_fmt(self, panic: impl FnOnce() -> !) -> T

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> FmtExpect<T> for Option<T>

Source§

fn expect_fmt(self, panic: impl FnOnce() -> !) -> T

Source§

impl<T, E> FmtExpect<T> for Result<T, E>

Source§

fn expect_fmt(self, panic: impl FnOnce() -> !) -> T

Implementors§