pub trait OptionExt: Sealed + Sized {
// Required methods
fn or_not_found<I>(
self,
entity: &'static str,
identifier: I,
) -> Result<Self::Value>
where I: Display;
fn or_not_found_unknown(self, entity: &'static str) -> Result<Self::Value>;
}
Expand description
Extension methods on Option<T>
.
Required Methods§
Sourcefn or_not_found<I>(
self,
entity: &'static str,
identifier: I,
) -> Result<Self::Value>where
I: Display,
fn or_not_found<I>(
self,
entity: &'static str,
identifier: I,
) -> Result<Self::Value>where
I: Display,
Returns Ok(_)
if the source is Some(_)
, otherwise, returns a
Problem
that can downcast to NotFound
.
§Errors
Returns Err
when self
is None
.
Sourcefn or_not_found_unknown(self, entity: &'static str) -> Result<Self::Value>
fn or_not_found_unknown(self, entity: &'static str) -> Result<Self::Value>
It’s a wrapper to or_not_found
to be used when
there is no a specific identifier to entity message.
Returns Ok(_)
if the source is Some(_)
, otherwise, returns a
Problem
that can downcast to NotFound
.
§Errors
Returns Err
when self
is None
.
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.