Struct fluent_builder::StatefulFluentBuilder
[−]
[src]
pub struct StatefulFluentBuilder<TValue, TSeed, TStack = Override, TFluent = BoxedFluent<TValue>> { /* fields omitted */ }
A stateful structure that can contain a value, or stack mutating methods over one supplied later.
Methods
impl<TValue, TSeed, TStack, TFluent> StatefulFluentBuilder<TValue, TSeed, TStack, TFluent>
[src]
fn from_value(value: TValue) -> Self
[src]
Create a new StatefulFluentBuilder
from the given value.
fn from_seed(seed: TSeed) -> Self
[src]
Create a new StatefulFluentBuilder
from the given seed.
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, TSeed, TStack> StatefulFluentBuilder<TValue, TSeed, TStack, BoxedFluent<TValue>>
[src]
fn from_fluent<TFluent>(
seed: TSeed,
fluent_method: TFluent
) -> StatefulFluentBuilder<TValue, TSeed, TStack, Apply<TValue, BoxedFluent<TValue>, ByValue<TFluent>>> where
TFluent: FnOnce(TValue) -> TValue,
[src]
seed: TSeed,
fluent_method: TFluent
) -> StatefulFluentBuilder<TValue, TSeed, TStack, Apply<TValue, BoxedFluent<TValue>, ByValue<TFluent>>> where
TFluent: FnOnce(TValue) -> TValue,
Create a new StatefulFluentBuilder
from the given seed and fluent method.
fn from_fluent_mut<TFluent>(
seed: TSeed,
fluent_method: TFluent
) -> StatefulFluentBuilder<TValue, TSeed, TStack, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TFluent>>> where
TFluent: FnOnce(&mut TValue),
[src]
seed: TSeed,
fluent_method: TFluent
) -> StatefulFluentBuilder<TValue, TSeed, TStack, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TFluent>>> where
TFluent: FnOnce(&mut TValue),
Create a new StatefulFluentBuilder
from the given seed and fluent method.
This method is the same as from_fluent
, but mutates the value instead of replacing it.
impl<TValue, TSeed, TStack, TFluent> StatefulFluentBuilder<TValue, TSeed, TStack, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn into_value<TDefault>(self, default_value: TDefault) -> TValue where
TDefault: FnOnce(TSeed) -> TValue + 'static,
[src]
TDefault: FnOnce(TSeed) -> 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 = StatefulFluentBuilder::<String, i32, Stack>::from_value("A value".to_owned()) .fluent(1, |s, i| format!("{} and more {}", s, i)); match builder.try_into_value() { TryIntoValue::Value(value) => { // The builder has a value that we can use assert_eq!("A value and more 1", value); }, TryIntoValue::Builder(builder) => { // The builder doesn't have a value but we can still use it let value = builder.into_value(|i| i.to_string()); } }
impl<TValue, TSeed, TFluent> StatefulFluentBuilder<TValue, TSeed, Stack, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn fluent<TNewFluent>(
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Stack, StatefulApply<TValue, TSeed, TFluent, ByValue<TNewFluent>>> where
TNewFluent: FnOnce(TValue, TSeed) -> TValue,
[src]
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Stack, StatefulApply<TValue, TSeed, TFluent, ByValue<TNewFluent>>> where
TNewFluent: FnOnce(TValue, TSeed) -> 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<TNewFluent>(
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Stack, StatefulApply<TValue, TSeed, TFluent, ByRefMut<TNewFluent>>> where
TNewFluent: FnOnce(&mut TValue, TSeed),
[src]
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Stack, StatefulApply<TValue, TSeed, TFluent, ByRefMut<TNewFluent>>> where
TNewFluent: FnOnce(&mut TValue, TSeed),
Stack a fluent method on the builder.
This method behaves the same as fluent
, but mutates the value instead of replacing it.
impl<TValue, TSeed, TFluent> StatefulFluentBuilder<TValue, TSeed, Override, TFluent> where
TFluent: Fluent<TValue>,
[src]
TFluent: Fluent<TValue>,
fn fluent<TNewFluent>(
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Override, Apply<TValue, BoxedFluent<TValue>, ByValue<TNewFluent>>> where
TNewFluent: FnOnce(TValue) -> TValue + 'static,
[src]
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Override, Apply<TValue, BoxedFluent<TValue>, ByValue<TNewFluent>>> where
TNewFluent: FnOnce(TValue) -> TValue + 'static,
Set the 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 remove that previous value.
- a previous fluent method, that method will be replaced with the given one.
fn fluent_mut<TNewFluent>(
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Override, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TNewFluent>>> where
TNewFluent: FnOnce(&mut TValue) + 'static,
[src]
self,
seed: TSeed,
fluent_method: TNewFluent
) -> StatefulFluentBuilder<TValue, TSeed, Override, Apply<TValue, BoxedFluent<TValue>, ByRefMut<TNewFluent>>> where
TNewFluent: 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, TSeed, TStack, TFluent> StatefulFluentBuilder<TValue, TSeed, TStack, TFluent> where
TFluent: 'static,
TSeed: 'static,
TFluent: Fluent<TValue> + 'static,
[src]
TFluent: 'static,
TSeed: 'static,
TFluent: Fluent<TValue> + 'static,
fn boxed(
self
) -> StatefulFluentBuilder<TValue, TSeed, TStack, BoxedFluent<TValue>>
[src]
self
) -> StatefulFluentBuilder<TValue, TSeed, TStack, BoxedFluent<TValue>>
Box a fluent builder so it can be easily shared.