FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    OptionExtensions

    trait · ferroui-dynamic-data · v0.5.0

    trait OptionExtensions<T>: Sized
    

    The extensions of an option (OptionExtensions on Optional<T>).

    View source

    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>)).

    Source

    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>>)).

    Source

    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).

    Source

    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>)).

    Source

    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>)).

    Source

    value_or_default

    fn value_or_default(self: Self) -> T
    where T: Default
    

    The value, or the default value of T (ValueOrDefault).

    Source

    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.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.