OptionExtensions
trait · ferroui-dynamic-data · v0.5.0
trait OptionExtensions<T>: Sized
The extensions of an option (OptionExtensions on Optional<T>).
Members
convert
fn convert<U>(self: Self, converter: impl FnOnce(T) -> U) -> Option<U>
The value converted by converter, or none (Convert(Func<TSource, TDestination>)).
convert_optional
fn convert_optional<U>(self: Self, converter: impl FnOnce(T) -> Option<U>) -> Option<U>
The option that converter makes of the value, or none
(Convert(Func<TSource, Optional<TDestination>>)).
convert_or
fn convert_or<U>(self: Self, converter: impl FnOnce(T) -> U, fallback_converter: impl FnOnce() -> U) -> U
The value converted by converter, or what fallback_converter makes when there is none
(ConvertOr).
if_has_value
fn if_has_value(self: Self, action: impl FnOnce(T) -> ()) -> OptionElse
Runs action with the value; the result runs its else_ action when there is none
(IfHasValue(Action<T>)).
value_or
fn value_or(self: Self, value_selector: impl FnOnce() -> T) -> T
The value, or what value_selector makes when there is none (ValueOr(Func<T>)).
value_or_default
fn value_or_default(self: Self) -> T
where T: Default
The value, or the default value of T (ValueOrDefault).
value_or_throw
fn value_or_throw<E>(self: Self, exception_generator: impl FnOnce() -> E) -> Result<T, E>
The value, or the error that exception_generator makes when there is none
(ValueOrThrow).
Deviation (DEVIATIONS.md, DynamicData): upstream throws the exception; the port returns it
as the Err of the result.
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.