pub enum Node {
List {
kind: ListKind,
items: Vec<Item>,
},
Atom(String),
Str(String),
Prefixed {
prefix: String,
inner: Box<Node>,
},
}Variants§
List
Atom(String)
Symbols, numbers, booleans (#t/#f), chars (#\x), keywords (#:k), and .
Str(String)
Raw string literal INCLUDING surrounding quotes, escapes as written.
Prefixed
prefix is one of: ’ , ,@ #' # #, #,@ #~ #$ #$@ #+ (gexp syntax).
Implementations§
Source§impl Node
impl Node
Sourcepub fn head_symbol(&self) -> Option<&str>
pub fn head_symbol(&self) -> Option<&str>
For a list, the text of its first data child if that child is an Atom.
Sourcepub fn as_string_lit(&self) -> Option<String>
pub fn as_string_lit(&self) -> Option<String>
Unescaped contents of a string literal.
Sourcepub fn list_nodes(&self) -> impl Iterator<Item = &Node>
pub fn list_nodes(&self) -> impl Iterator<Item = &Node>
Data children of a list, trivia skipped. Empty for non-lists.
Source§impl Node
impl Node
pub fn data_child(&self, data_index: usize) -> Option<&Node>
pub fn data_child_mut(&mut self, data_index: usize) -> Option<&mut Node>
Sourcepub fn position_of<F: Fn(&Node) -> bool>(&self, pred: F) -> Option<usize>
pub fn position_of<F: Fn(&Node) -> bool>(&self, pred: F) -> Option<usize>
Data index of the first child matching PRED.
Sourcepub fn insert_child(&mut self, data_index: usize, node: Node)
pub fn insert_child(&mut self, data_index: usize, node: Node)
Insert NODE before the DATA_INDEX-th data child; trivia stays attached to its original neighbor. Out-of-range appends.
Sourcepub fn push_child(&mut self, node: Node)
pub fn push_child(&mut self, node: Node)
Insert NODE after the last data child (before trailing trivia/close).
pub fn replace_child(&mut self, data_index: usize, node: Node) -> bool
Sourcepub fn remove_child(
&mut self,
data_index: usize,
take_leading_trivia: bool,
) -> Option<Node>
pub fn remove_child( &mut self, data_index: usize, take_leading_trivia: bool, ) -> Option<Node>
Remove the DATA_INDEX-th data child. With TAKE_LEADING_TRIVIA, the comments and blanks between the previous data child and this one go with it; otherwise only directly adjacent whitespace is dropped.