pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Array(Vec<Value>),
Object(HashMap<String, Value>),
}Expand description
A runtime value in the Gracile template engine.
Variants§
Null
Bool(bool)
Int(i64)
Float(f64)
String(String)
Array(Vec<Value>)
Object(HashMap<String, Value>)
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
false, null, 0, 0.0, and "" are falsy. Everything else
(including empty arrays []) is truthy.
pub fn is_null(&self) -> bool
pub fn type_name(&self) -> &'static str
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Returns the display string for this value (used in interpolation).
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Serialises the value as a JSON string.
Sourcepub fn html_escaped(&self) -> String
pub fn html_escaped(&self) -> String
Returns the HTML-escaped display string (safe for insertion into HTML).
pub fn length(&self) -> Option<usize>
pub fn is_empty(&self) -> bool
Trait Implementations§
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more