Struct mustache::MapBuilder [] [src]

pub struct MapBuilder { /* fields omitted */ }

MapBuilder is a helper type that construct Data types.

Methods

impl MapBuilder
[src]

[src]

Create a MapBuilder

[src]

Add an Encodable to the MapBuilder.

use mustache::MapBuilder;
let data = MapBuilder::new()
    .insert("name", &("Jane Austen")).expect("Failed to encode name")
    .insert("age", &41usize).expect("Failed to encode age")
    .build();

[src]

Add a String to the MapBuilder.

use mustache::MapBuilder;
let data = MapBuilder::new()
    .insert_str("name", "Jane Austen")
    .build();

[src]

Add a bool to the MapBuilder.

use mustache::MapBuilder;
let data = MapBuilder::new()
    .insert_bool("show", true)
    .build();

[src]

Add a Vec to the MapBuilder.

use mustache::MapBuilder;
let data = MapBuilder::new()
    .insert_vec("authors", |builder| {
        builder
            .push_str("Jane Austen")
            .push_str("Lewis Carroll")
    })
    .build();

[src]

Add a Map to the MapBuilder.

use mustache::MapBuilder;
let data = MapBuilder::new()
    .insert_map("person1", |builder| {
        builder
            .insert_str("first_name", "Jane")
            .insert_str("last_name", "Austen")
    })
    .insert_map("person2", |builder| {
        builder
            .insert_str("first_name", "Lewis")
            .insert_str("last_name", "Carroll")
    })
    .build();

[src]

Add a function to the MapBuilder.

use mustache::MapBuilder;
let mut count = 0;
let data = MapBuilder::new()
    .insert_fn("increment", move |_| {
        count += 1usize;
        count.to_string()
    })
    .build();

[src]

Return the built Data.

Trait Implementations

impl Default for MapBuilder
[src]

[src]

Returns the "default value" for a type. Read more