Enum gtmpl_value::Value[][src]

pub enum Value {
    NoValue,
    Nil,
    Bool(bool),
    String(String),
    Object(HashMap<String, Value>),
    Map(HashMap<String, Value>),
    Array(Vec<Value>),
    Function(Function),
    Number(Number),
}
Expand description

Represents a gtmpl value.

Variants

NoValue
Nil
Bool(bool)
String(String)
Object(HashMap<String, Value>)
Array(Vec<Value>)
Function(Function)
Number(Number)

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Convert Slice to Value

Examples

use gtmpl_value::Value;

let v: &[i32] = &[1, 2, 3];
let x: Value = v.into();

Convert &String to Value

Examples

use gtmpl_value::Value;

let s: &String = &"foobar".to_owned();
let x: Value = s.into();

Convert &str to Value

Examples

use gtmpl_value::Value;

let s = "foobar";
let x: Value = s.into();

Convert Cow to Value

Examples

use gtmpl_value::Value;
use std::borrow::Cow;

let s: Cow<str> = Cow::Borrowed("foobar");
let x: Value = s.into();

Convert HashMap<String, T> to Value

Examples

use gtmpl_value::Value;
use std::collections::HashMap;

let mut m = HashMap::new();
m.insert("hello".to_owned(), 123);
let x: Value = m.into();

Convert Option to Value

Examples

use gtmpl_value::Value;

let i = Some(1);
let x: Value = i.into();

Convert String to Value

Examples

use gtmpl_value::Value;

let s: String = "foobar".to_owned();
let x: Value = s.into();

Convert Vec to Value

Examples

use gtmpl_value::Value;

let v = vec!(1, 2, 3);
let x: Value = v.into();

Convert boolean to Value

Examples

use gtmpl_value::Value;

let b = false;
let x: Value = b.into();

Performs the conversion.

Performs the conversion.

Convert Func to Value

Examples

use gtmpl_value::{Func, FuncError, Value};

fn f(a: &[Value]) -> Result<Value, FuncError> {
    Ok(a[0].clone())
};
let x: Value = (f as Func).into();

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.