pub enum Value {
Struct(Struct),
Tuple(Tuple),
List(List),
Map(Map),
EnumVariant(EnumVariant),
Unit(Unit),
Literal(Literal),
Error(SyntaxNode),
}Expand description
A typed RON value: the classified wrapper for any value-position node.
Returned by the value accessors (Document::value, StructField::value,
MapEntry::key/MapEntry::value, and the items() iterators). The
Error / unknown arm keeps navigation total over error-recovered trees
(INV-3): a malformed value is still reachable as Value::Error rather than
silently dropped.
Variants§
Struct(Struct)
A named or anonymous struct Name( field: v, .. ) / ( field: v, .. ).
Tuple(Tuple)
A positional tuple / tuple-struct ( a, b, c ).
List(List)
A list / sequence [ a, b, c ].
Map(Map)
A map { k: v, .. } (keys may be non-string values).
EnumVariant(EnumVariant)
An enum variant: bare Ident, or Ident(..) / Ident{..} payload.
Unit(Unit)
The unit value ().
Literal(Literal)
A scalar literal (int, float, string, raw string, char, bool).
Error(SyntaxNode)
An unparseable / recovered value node (Error kind). Kept reachable so
navigation is total over error-recovered trees (INV-3).
Implementations§
Source§impl Value
impl Value
Sourcepub fn cast(node: SyntaxNode) -> Option<Self>
pub fn cast(node: SyntaxNode) -> Option<Self>
Classify a value-position SyntaxNode into a typed Value.
Returns None only for a node whose kind is not a value (e.g. Root,
StructField, MapEntry, ExtensionAttr) — callers that already hold a
value-position node always get Some.
Sourcepub fn syntax(&self) -> &SyntaxNode
pub fn syntax(&self) -> &SyntaxNode
The underlying SyntaxNode, regardless of variant.