Skip to main content

OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
    // Required method
    fn ok_or_err(self, msg: impl Into<String>) -> Result<T>;
}
Expand description

Extension trait for Option types

Required Methods§

Source

fn ok_or_err(self, msg: impl Into<String>) -> Result<T>

Convert None to an error with message

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

Source§

fn ok_or_err(self, msg: impl Into<String>) -> Result<T>

Implementors§