pub struct Node { /* private fields */ }Expand description
An AST node: an insertion-ordered string-keyed map.
Like Value, every traversal of it is iterative rather than derived.
Implementations§
Source§impl Node
impl Node
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
A mutable reference to the value at key, if the key is present.
Sourcepub fn set(&mut self, key: impl Into<String>, value: impl Into<Value>)
pub fn set(&mut self, key: impl Into<String>, value: impl Into<Value>)
Set key, keeping its existing position when it is already present
(as assigning to a JavaScript object property does).
Sourcepub fn push_to(&mut self, key: &str, value: Value)
pub fn push_to(&mut self, key: &str, value: Value)
Append to the list at key, creating the list if it is absent.
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
This node as JSON. Keys holding Value::Undefined are omitted.
Trait Implementations§
Source§impl Drop for Node
Dismantle a node iteratively when it is dropped.
impl Drop for Node
Dismantle a node iteratively when it is dropped.
An AST is as deep as the CSS that produced it, and a derived drop would recurse once per level — so a stylesheet nested a few thousand rules deep would abort the process, on nothing worse than untrusted input, at the moment the tree went out of scope. The engine keeps its own rule stack for the same reason; this is the other half of that promise.