Struct VecBuilder

Source
pub struct VecBuilder<'a> {
    pub data: Vec<Data<'a>>,
}
Expand description

VecBuilder is a helper type that constructs Data types in a Vector

Fields§

§data: Vec<Data<'a>>

The data contained within

Implementations§

Source§

impl<'a> VecBuilder<'a>

Source

pub fn new() -> VecBuilder<'a>

Create a new VecBuilder instance

Source

pub fn push<V>(self, value: V) -> VecBuilder<'a>
where V: Into<Data<'a>>,

Add a Into<Data> to the VecBuilder

use rustache::VecBuilder;
use std::convert::Into;
let data = VecBuilder::new()
    .push("Mage")
    .push("Druid");
use rustache::VecBuilder;
let data = VecBuilder::new()
    .push(VecBuilder::new()
            .push("Anduin Wrynn".to_string())
            .push("Jaina Proudmoore".to_string())
    );
use rustache::{HashBuilder, VecBuilder};
let data = VecBuilder::new()
    .push(HashBuilder::new()
            .insert("first_name".to_string(), "Garrosh".to_string())
            .insert("last_name".to_string(), "Hellscream".to_string())
    )
    .push(HashBuilder::new()
            .insert("first_name".to_string(), "Malfurion".to_string())
            .insert("last_name".to_string(), "Stormrage".to_string())
    );
Source

pub fn push_lambda( self, f: &'a mut dyn FnMut(String) -> String, ) -> VecBuilder<'a>

Add a Lambda to the VecBuilder

use rustache::VecBuilder;
let mut f = |_| { "world".to_string() };
let data = VecBuilder::new()
    .push_lambda(&mut f);

Auto Trait Implementations§

§

impl<'a> Freeze for VecBuilder<'a>

§

impl<'a> !RefUnwindSafe for VecBuilder<'a>

§

impl<'a> !Send for VecBuilder<'a>

§

impl<'a> !Sync for VecBuilder<'a>

§

impl<'a> Unpin for VecBuilder<'a>

§

impl<'a> !UnwindSafe for VecBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.