Skip to main content

MaybeExt

Trait MaybeExt 

pub trait MaybeExt: Sized {
    // Provided methods
    fn maybe(
        self,
        bool: impl Into<bool>,
        then: impl FnOnce(Self) -> Self,
    ) -> Self { ... }
    fn map<T>(self, data: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self { ... }
}
Expand description

Methods for applying changes to an element conditionally.

Provided Methods§

fn maybe(self, bool: impl Into<bool>, then: impl FnOnce(Self) -> Self) -> Self

Apply then to the element only when the condition is true.

fn map<T>(self, data: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self

Apply then to the element only when the Option is Some, passing the inner value.

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.

Implementors§

Source§

impl MaybeExt for Canvas

Source§

impl MaybeExt for Gif

§

impl MaybeExt for Image

§

impl MaybeExt for Label

§

impl MaybeExt for Paragraph

§

impl MaybeExt for Rect

§

impl MaybeExt for Svg

§

impl<T> MaybeExt for T
where T: Component,