Skip to main content

MapExpect

Trait MapExpect 

Source
pub trait MapExpect<'a, T> {
    // Required method
    fn map_expect(self, msg: &'a str) -> T;
}
Expand description

Applies an expectation to a nested optional or fallible value.

Implementations cover Option<Result<T, E>> and Result<Option<T>, E>. Only the nested value is unwrapped, preserving the outer container.

Required Methods§

Source

fn map_expect(self, msg: &'a str) -> T

Unwraps the nested value with the supplied expectation message.

The outer Option or Result is preserved. The message is used only when the nested value is absent or failed.

§Panics

Panics when the nested value does not contain a success value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<'a, T, E: Debug> MapExpect<'a, Option<T>> for Option<Result<T, E>>

Source§

fn map_expect(self, msg: &'a str) -> Option<T>

Implementors§

Source§

impl<'a, T, E: Debug> MapExpect<'a, Result<T, E>> for Result<Option<T>, E>