pub enum Value {
NoValue,
Nil,
Bool(bool),
String(String),
Object(HashMap<String, Value, RandomState>),
Map(HashMap<String, Value, RandomState>),
Array(Vec<Value, Global>),
Function(Function),
Number(Number),
}
Expand description
Represents a gtmpl value.
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
use gtmpl_value::Value;
let v: &[i32] = &[1, 2, 3];
let x: Value = v.into();
Convert &String to Value
use gtmpl_value::Value;
let s: &String = &"foobar".to_owned();
let x: Value = s.into();
Convert &str to Value
use gtmpl_value::Value;
let s = "foobar";
let x: Value = s.into();
Convert Cow to Value
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
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
use gtmpl_value::Value;
let i = Some(1);
let x: Value = i.into();
Convert String to Value
use gtmpl_value::Value;
let s: String = "foobar".to_owned();
let x: Value = s.into();
Convert Vec to Value
use gtmpl_value::Value;
let v = vec!(1, 2, 3);
let x: Value = v.into();
Convert boolean to Value
use gtmpl_value::Value;
let b = false;
let x: Value = b.into();
Convert Func to Value
use gtmpl_value::{Func, FuncError, Value};
fn f(a: &[Value]) -> Result<Value, FuncError> {
Ok(a[0].clone())
};
let x: Value = (f as Func).into();
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
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.
The type returned in the event of a conversion error.