Trait polkadot_sdk_frame::traits::DefensiveResult
pub trait DefensiveResult<T, E> {
// Required methods
fn defensive_map_err<F, O>(self, o: O) -> Result<T, F>
where O: FnOnce(E) -> F;
fn defensive_map_or_else<U, D, F>(self, default: D, f: F) -> U
where D: FnOnce(E) -> U,
F: FnOnce(T) -> U;
fn defensive_ok(self) -> Option<T>;
fn defensive_map<U, F>(self, f: F) -> Result<U, E>
where F: FnOnce(T) -> U;
}
Expand description
Subset of methods similar to Defensive
that can only work for a Result
.
Required Methods§
fn defensive_map_err<F, O>(self, o: O) -> Result<T, F>where
O: FnOnce(E) -> F,
fn defensive_map_err<F, O>(self, o: O) -> Result<T, F>where
O: FnOnce(E) -> F,
Defensively map the error into another return type, but you are really sure that this conversion should never be needed.
fn defensive_map_or_else<U, D, F>(self, default: D, f: F) -> U
fn defensive_map_or_else<U, D, F>(self, default: D, f: F) -> U
Defensively map and unpack the value to something else (U
), or call the default callback
if Err
, which should never happen.
fn defensive_ok(self) -> Option<T>
fn defensive_ok(self) -> Option<T>
Defensively transform this result into an option, discarding the Err
variant if it
happens, which should never happen.
fn defensive_map<U, F>(self, f: F) -> Result<U, E>where
F: FnOnce(T) -> U,
fn defensive_map<U, F>(self, f: F) -> Result<U, E>where
F: FnOnce(T) -> U,
Exactly the same as map
, but it prints the appropriate warnings if the value being mapped
is Err
.
Object Safety§
This trait is not object safe.