Struct mustache::builder::VecBuilder
[−]
[src]
pub struct VecBuilder { // some fields omitted }
Methods
impl<'a> VecBuilder
fn new() -> VecBuilder
Create a VecBuilder
fn push<T: Encodable>(self, value: &T) -> Result<VecBuilder, Error>
Add an Encodable
to the VecBuilder
.
use mustache::{VecBuilder, Data}; let data: Data = VecBuilder::new() .push(& &"Jane Austen").ok().unwrap() .push(&41usize).ok().unwrap() .build();
fn push_str<T: ToString>(self, value: T) -> VecBuilder
Add a String
to the VecBuilder
.
use mustache::VecBuilder; let data = VecBuilder::new() .push_str("Jane Austen") .push_str("Lewis Carroll") .build();
fn push_bool(self, value: bool) -> VecBuilder
Add a bool
to the VecBuilder
.
use mustache::VecBuilder; let data = VecBuilder::new() .push_bool(false) .push_bool(true) .build();
fn push_vec<F>(self, f: F) -> VecBuilder where F: FnMut(VecBuilder) -> VecBuilder
Add a Vec
to the MapBuilder
.
use mustache::VecBuilder; let data = VecBuilder::new() .push_vec(|builder| { builder .push_str("Jane Austen".to_string()) .push_str("Lewis Carroll".to_string()) }) .build();
fn push_map<F>(self, f: F) -> VecBuilder where F: FnMut(MapBuilder) -> MapBuilder
Add a Map
to the VecBuilder
.
use mustache::VecBuilder; let data = VecBuilder::new() .push_map(|builder| { builder .insert_str("first_name".to_string(), "Jane".to_string()) .insert_str("last_name".to_string(), "Austen".to_string()) }) .push_map(|builder| { builder .insert_str("first_name".to_string(), "Lewis".to_string()) .insert_str("last_name".to_string(), "Carroll".to_string()) }) .build();
fn push_fn<F>(self, f: F) -> VecBuilder where F: FnMut(String) -> String + Send + 'static
Add a function to the VecBuilder
.
use mustache::VecBuilder; let mut count = 0; let data = VecBuilder::new() .push_fn(move |s| { count += 1usize; s + &count.to_string() }) .build();