pub type AstNode<'a> = Node<'a, RefCell<Ast>>;Expand description
The type of a node within the document.
It is bound by the lifetime 'a, which corresponds to the Arena nodes are
allocated in. Child Asts are wrapped in RefCell for interior mutability.
You can construct a new AstNode from a NodeValue using the From trait:
let root = AstNode::from(NodeValue::Document);Note that no sourcepos information is given to the created node. If you wish
to assign sourcepos information, use the From trait to create an AstNode
from an Ast:
let root = AstNode::from(Ast::new(
NodeValue::Paragraph,
(4, 1).into(), // start_line, start_col
));Adjust the end position manually.
For practical use, you’ll probably need it allocated in an Arena, in which
case you can use .into() to simplify creation:
let node_in_arena = arena.alloc(NodeValue::Document.into());Aliased Type§
pub struct AstNode<'a> {
pub data: RefCell<Ast>,
/* private fields */
}Fields§
§data: RefCell<Ast>The data held by the node.