[−][src]Struct fluent_builder::FluentBuilder
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, TStorage> FluentBuilder<TValue, TStack, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
impl<TValue, TStack, TStorage> FluentBuilder<TValue, TStack, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
pub 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, TStorage> FluentBuilder<TValue, Stack, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
pub fn fluent<TNextMethod>(
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Stack, Apply<TValue, TStorage::Method, ByValue<TNextMethod>>> where
TNextMethod: FnOnce(TValue) -> TValue,
[src]
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Stack, Apply<TValue, TStorage::Method, ByValue<TNextMethod>>> where
TNextMethod: 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.
pub fn fluent_mut<TNextMethod>(
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Stack, Apply<TValue, TStorage::Method, ByRefMut<TNextMethod>>> where
TNextMethod: FnOnce(&mut TValue),
[src]
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Stack, Apply<TValue, TStorage::Method, ByRefMut<TNextMethod>>> where
TNextMethod: 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, TStorage> FluentBuilder<TValue, Override, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
pub fn fluent<TNextMethod>(
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Override, Apply<TValue, DefaultStorage, ByValue<TNextMethod>>> where
TNextMethod: FnOnce(TValue) -> TValue + 'static,
[src]
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Override, Apply<TValue, DefaultStorage, ByValue<TNextMethod>>> where
TNextMethod: FnOnce(TValue) -> TValue + 'static,
Create a new StatefulFluentBuilder
from the given value.
pub fn fluent_mut<TNextMethod>(
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Override, Apply<TValue, DefaultStorage, ByRefMut<TNextMethod>>> where
TNextMethod: FnOnce(&mut TValue) + 'static,
[src]
self,
fluent_method: TNextMethod
) -> FluentBuilder<TValue, Override, Apply<TValue, DefaultStorage, ByRefMut<TNextMethod>>> where
TNextMethod: 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, TStorage> FluentBuilder<TValue, TStack, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
pub 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.
pub 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, TStorage> FluentBuilder<TValue, TStack, TStorage> where
TValue: 'static,
TStorage: Storage<TValue> + 'static,
[src]
TValue: 'static,
TStorage: Storage<TValue> + 'static,
pub fn boxed(self) -> BoxedFluentBuilder<TValue, TStack>
[src]
Box a fluent builder so it can be easily captured as a field without generics.
impl<TValue, TStack, TStorage> FluentBuilder<TValue, TStack, TStorage> where
TValue: 'static,
TStorage: Storage<TValue>,
TStorage::Method: Send + 'static,
[src]
TValue: 'static,
TStorage: Storage<TValue>,
TStorage::Method: Send + 'static,
pub fn shared(self) -> SharedFluentBuilder<TValue, TStack>
[src]
Box a fluent builder so it can be easily shared.
Trait Implementations
impl<TValue, TStack, TStorage> Default for FluentBuilder<TValue, TStack, TStorage> where
TStorage: Storage<TValue>,
[src]
TStorage: Storage<TValue>,
Auto Trait Implementations
impl<TValue, TStack, TStorage> Send for FluentBuilder<TValue, TStack, TStorage> where
TStack: Send,
TValue: Send,
<TStorage as Storage<TValue>>::Method: Send,
TStack: Send,
TValue: Send,
<TStorage as Storage<TValue>>::Method: Send,
impl<TValue, TStack, TStorage> Sync for FluentBuilder<TValue, TStack, TStorage> where
TStack: Sync,
TValue: Sync,
<TStorage as Storage<TValue>>::Method: Sync,
TStack: Sync,
TValue: Sync,
<TStorage as Storage<TValue>>::Method: Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,