Trait tea_sdk::vmh::OptionExt

pub trait OptionExt {
    type Value;

    // Required methods
    fn ok_or_err(self, name: impl Into<String>) -> Result<Self::Value, Global>;
    fn ok_or_err_else<N, F>(
        self,
        name_factory: F
    ) -> Result<Self::Value, Global>
       where N: Into<String>,
             F: FnOnce() -> N;
}
Expand description

A helper trait to map None conditions to tea Errors

Required Associated Types§

type Value

Required Methods§

fn ok_or_err(self, name: impl Into<String>) -> Result<Self::Value, Global>

Map None condition to an error message with a const name of some value that is expected not to be None.

fn ok_or_err_else<N, F>(self, name_factory: F) -> Result<Self::Value, Global>where N: Into<String>, F: FnOnce() -> N,

Map None condition to an error message with a function generatred name of some value that is expected not to be None.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<T> OptionExt for Option<T>

§

type Value = T

§

fn ok_or_err( self, name: impl Into<String> ) -> Result<<Option<T> as OptionExt>::Value, Global>

§

fn ok_or_err_else<N, F>( self, name_factory: F ) -> Result<<Option<T> as OptionExt>::Value, Global>where N: Into<String>, F: FnOnce() -> N,

Implementors§