Skip to main content

StoreResultExt

Trait StoreResultExt 

Source
pub trait StoreResultExt<T, E: StoreErrorPredicates> {
    // Required method
    fn optional(self) -> Result<Option<T>, E>;
}
Expand description

Extension methods for store results.

Required Methods§

Source

fn optional(self) -> Result<Option<T>, E>

Converts a “key not found” error into absence.

Mapping:

  • Ok(v) -> Ok(Some(v))
  • Err(e) where e.is_key_not_found() -> Ok(None)
  • any other Err(e) -> Err(e)

This method does not panic.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, E: StoreErrorPredicates> StoreResultExt<T, E> for Result<T, E>

Source§

fn optional(self) -> Result<Option<T>, E>

Implementors§