Enum Value
Source 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.
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();
Converts to this type from the input type.
Converts to this type from the input type.
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();
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
🔬This is a nightly-only experimental API. (clone_to_uninit
)
Performs copy-assignment from
self
to
dest
.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
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.