pub enum Value {
Undefined,
Null,
Bool(bool),
Num(f64),
Str(String),
List(Vec<Value>),
Node(Node),
}Expand description
A value held by an AST node field.
Every traversal of a value is ITERATIVE: dropping, cloning, comparing,
writing it as JSON and formatting it for std::fmt::Debug. An AST is as
deep as the CSS that produced it, so a derived implementation of any of
them would recurse once per level and abort the process on nothing worse
than untrusted input. None of them is derived, for that reason.
Variants§
Undefined
A key that exists but serialises to nothing (JavaScript undefined).
Null
JSON null.
Bool(bool)
JSON true / false.
Num(f64)
A JSON number. Integral values serialise without a decimal point.
Str(String)
A JSON string.
List(Vec<Value>)
A JSON array.
Node(Node)
A nested AST node (a JSON object).
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
The string held here, if this is a Value::Str.
Sourcepub fn as_node(&self) -> Option<&Node>
pub fn as_node(&self) -> Option<&Node>
The node held here, if this is a Value::Node.
Sourcepub fn as_list(&self) -> Option<&[Value]>
pub fn as_list(&self) -> Option<&[Value]>
The list held here, if this is a Value::List.
Trait Implementations§
Source§impl Debug for Value
The debug view is the JSON, with Undefined keys shown rather than
dropped.
impl Debug for Value
The debug view is the JSON, with Undefined keys shown rather than
dropped.
Not derived, and not a struct-shaped {:#?} dump. A derived formatter
recurses once per nesting level, so format!("{ast:?}") on a stylesheet a
few thousand rules deep aborts the process — on an AST whose parse, drop
and serialisation are all depth-safe, and in the one operation a caller
reaches for while debugging. This shares the iterative writer instead.