Skip to main content

FluentBuilder

Trait FluentBuilder 

Source
pub trait FluentBuilder {
    // Provided methods
    fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
       where Self: Sized { ... }
    fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
       where Self: Sized { ... }
    fn when_else(
        self,
        condition: bool,
        then: impl FnOnce(Self) -> Self,
        else_fn: impl FnOnce(Self) -> Self,
    ) -> Self
       where Self: Sized { ... }
    fn when_some<T>(
        self,
        option: Option<T>,
        then: impl FnOnce(Self, T) -> Self,
    ) -> Self
       where Self: Sized { ... }
    fn when_none<T>(
        self,
        option: &Option<T>,
        then: impl FnOnce(Self) -> Self,
    ) -> Self
       where Self: Sized { ... }
}
Expand description

A helper trait for building complex objects with imperative conditionals in a fluent style.

Provided Methods§

Source

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.

Source

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.

Source

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.

Source

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.

Source

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§