Struct fluent_builder::FluentBuilder
[−]
[src]
pub struct FluentBuilder<TValue, TStack = Override, TFluent = BoxedFluent<TValue>> { /* fields omitted */ }
A structure that can contain a value, or stack mutating methods over one supplied later.
The FluentBuilder<T>
is effectively a StatefulFluentBuilder<T, ()>
.
Methods
impl<TValue, TStack> FluentBuilder<TValue, TStack, BoxedFluent<TValue>>
[src]
impl<TValue, TStack, TFluent> FluentBuilder<TValue, TStack, TFluent>
[src]
fn value(self, value: TValue) -> Self
[src]
Set a value on the builder.
This will override any contained state. That means if the builder currently contains fluent methods then those methods will be discarded.
impl<TValue, TFluent> FluentBuilder<TValue, Stack, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn fluent<TNextFluent>(
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Stack, Apply<TValue, TFluent, ByValue<TNextFluent>>> where
TNextFluent: FnOnce(TValue) -> TValue,
[src]
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Stack, Apply<TValue, TFluent, ByValue<TNextFluent>>> where
TNextFluent: FnOnce(TValue) -> TValue,
Stack a fluent method on the builder.
This will have the following behaviour depending on the current state of the builder if there is:
- no previous value, add the fluent method. This will be applied to a later-supplied default value.
- a previous value, add the fluent method and retain that previous value.
- a previous fluent method, stack this method on top and retain any previous value.
fn fluent_mut<TNextFluent>(
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Stack, Apply<TValue, TFluent, ByRefMut<TNextFluent>>> where
TNextFluent: FnOnce(&mut TValue),
[src]
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Stack, Apply<TValue, TFluent, ByRefMut<TNextFluent>>> where
TNextFluent: FnOnce(&mut TValue),
Stack a fluent method on the builder.
This method behaves the same as fluent
, but mutates the value instead of replacing it.
impl<TValue, TFluent> FluentBuilder<TValue, Override, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn fluent<TNextFluent>(
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Override, Apply<TValue, BoxedFluent<TValue>, ByValue<TNextFluent>>> where
TNextFluent: FnOnce(TValue) -> TValue + 'static,
[src]
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Override, Apply<TValue, BoxedFluent<TValue>, ByValue<TNextFluent>>> where
TNextFluent: FnOnce(TValue) -> TValue + 'static,
Create a new StatefulFluentBuilder
from the given value.
fn fluent_mut<TNextFluent>(
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Override, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TNextFluent>>> where
TNextFluent: FnOnce(&mut TValue) + 'static,
[src]
self,
fluent_method: TNextFluent
) -> FluentBuilder<TValue, Override, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TNextFluent>>> where
TNextFluent: FnOnce(&mut TValue) + 'static,
Set the fluent method on the builder.
This method behaves the same as fluent
, but mutates the value instead of replacing it.
impl<TValue, TStack, TFluent> FluentBuilder<TValue, TStack, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn into_value<TDefault>(self, default_value: TDefault) -> TValue where
TDefault: FnOnce() -> TValue + 'static,
[src]
TDefault: FnOnce() -> TValue + 'static,
Convert the fluent builder into a value.
This method will consume the builder and return a constructed T
.
This will have the following behaviour if the builder contains:
- no value or fluent methods, then the default value is constructed.
- a value, then that value is returned.
- no value but fluent methods, then the methods are applied over the default value.
- a value and fluent methods, then the methods are applied over that value.
fn try_into_value(self) -> TryIntoValue<TValue, Self>
[src]
Attempt to take a value from the builder.
If the builder doesn't contain a concrete value then it is returned in the Builder
variant.
Examples
let builder = FluentBuilder::<String, Stack>::new() .value("A value".to_owned()) .fluent_mut(|mut s| s.push_str(" and more")); match builder.try_into_value() { TryIntoValue::Value(value) => { // The builder has a value that we can use assert_eq!("A value and more", value); }, TryIntoValue::Builder(builder) => { // The builder doesn't have a value but we can still use it let value = builder.into_value(|| String::new()); } }
impl<TValue, TStack, TFluent> FluentBuilder<TValue, TStack, TFluent> where
TValue: 'static,
TFluent: Fluent<TValue> + 'static,
[src]
TValue: 'static,
TFluent: Fluent<TValue> + 'static,
fn boxed(self) -> FluentBuilder<TValue, TStack, BoxedFluent<TValue>>
[src]
Box a fluent builder so it can be easily shared.