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§
Sourcefn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Imperatively modify self with the given closure.
Sourcefn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
Sourcefn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".