Trait DecrustOptionExt

Source
pub trait DecrustOptionExt<T> {
    // Required methods
    fn decrust_ok_or_missing_value(
        self,
        item_description: &str,
    ) -> Result<T, DecrustError>;
    fn decrust_ok_or_missing_value_owned(
        self,
        item_description: String,
    ) -> Result<T, DecrustError>;
}
Expand description

Extension trait for Option types to convert to Result with DecrustError

This trait provides methods to convert an Option to a Result, with a MissingValue error if the Option is None.

This trait is object-safe and can be used with dynamic dispatch.

Required Methods§

Source

fn decrust_ok_or_missing_value( self, item_description: &str, ) -> Result<T, DecrustError>

Converts an Option to a Result, with a MissingValue error if None

§Parameters
  • item_description - Description of the missing value for the error message
§Returns

Ok(value) if the Option is Some(value), Err(DecrustError::MissingValue) otherwise

Source

fn decrust_ok_or_missing_value_owned( self, item_description: String, ) -> Result<T, DecrustError>

Converts an Option to a Result, with a MissingValue error if None (owned string version)

§Parameters
  • item_description - Description of the missing value for the error message
§Returns

Ok(value) if the Option is Some(value), Err(DecrustError::MissingValue) otherwise

Implementations on Foreign Types§

Source§

impl<T> DecrustOptionExt<T> for Option<T>

Source§

fn decrust_ok_or_missing_value( self, item_description: &str, ) -> Result<T, DecrustError>

Source§

fn decrust_ok_or_missing_value_owned( self, item_description: String, ) -> Result<T, DecrustError>

Implementors§