SafeOption

Trait SafeOption 

Source
pub trait SafeOption<T> {
    // Required methods
    fn safe_get(&self) -> Result<&T, ErrorInfo>;
    fn safe_get_msg<S: Into<String>>(&self, msg: S) -> Result<&T, ErrorInfo>;
    fn ok_msg(self, err: impl Into<String>) -> Result<T, ErrorInfo>;
}

Required Methods§

Source

fn safe_get(&self) -> Result<&T, ErrorInfo>

Source

fn safe_get_msg<S: Into<String>>(&self, msg: S) -> Result<&T, ErrorInfo>

Source

fn ok_msg(self, err: impl Into<String>) -> Result<T, ErrorInfo>

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

Source§

fn safe_get(&self) -> Result<&T, ErrorInfo>

Source§

fn safe_get_msg<S: Into<String>>(&self, msg: S) -> Result<&T, ErrorInfo>

Source§

fn ok_msg(self, err: impl Into<String>) -> RgResult<T>

Implementors§