Expand description
gtmpl_value_ng holds the value type used by gtmpl-ng, the Golang
templating language for Rust. A Value is what a template parses its literals
into and what a context hands it back.
The From trait is implemented for:
String,&str,Cow<str>- most numeric types
u64, u32, …, i64, i32, …, f64, f32 boolVec<Value>,&[Value]HashMap<String, Value>Option<T>, whereNonebecomesValue::NoValue
gtmpl_derive_ng derives it for a struct.
§Examples
use gtmpl_value_ng::Value;
let v: Value = "something".into();
assert_eq!(v.to_string(), "something");§Relation to gtmpl_value
This crate is a fork of gtmpl_value by Florian Dieminger, taken
from its master branch at a333139 — which is two years ahead of the last
release on crates.io and carries the fix for negative non-integer numbers that
0.5.1 truncates. It lives in the same workspace as the engine so that the value
type and the engine are released together.
With the gtmpl_value_compat feature, Value gains a TryFrom conversion from
gtmpl_value::Value, so a tree that still derives against the published crate can
be migrated one call site at a time.
Structs§
Enums§
- Float
Format - Which of Go’s float formats to use.
- From
Legacy Value Error - Why a
gtmpl_value::Valuecould not be converted. - Func
Error - Number
Kind - Which of the three representations a
Numberholds. - Value
- Represents a gtmpl value.
Traits§
- From
Value - Convert Value into something.
Functions§
- format_
float - Formats a float the way Go’s
strconv.FormatFloatdoes. - from_
value FromValuewrapped in a macro (required forgtmpl_fn!macro).- write_
float - Writes a float the way Go’s
strconv.FormatFloatdoes.
Type Aliases§
- Func
- Function type supported by
gtmpl_value_ng.