Trait mz_ore::option::FallibleMapExt

source ·
pub trait FallibleMapExt<T, U, E> {
    // Required method
    fn try_map<F>(&self, f: F) -> Result<Option<U>, E>
       where F: FnOnce(&T) -> Result<U, E>;
}
Expand description

From https://github.com/rust-lang/rust/issues/38282#issuecomment-266275785

Extend Option with a fallible map method.

(Note that the usual collect trick can’t be used with Option, unless I’m missing something.)

§Type parameters

  • T: The input Option’s value type
  • U: The outputs Option’s value type
  • E: The possible error during the mapping

Required Methods§

source

fn try_map<F>(&self, f: F) -> Result<Option<U>, E>
where F: FnOnce(&T) -> Result<U, E>,

Try to apply a fallible map function to the option

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T, U, E> FallibleMapExt<T, U, E> for Option<T>

source§

fn try_map<F>(&self, f: F) -> Result<Option<U>, E>
where F: FnOnce(&T) -> Result<U, E>,

Implementors§