pub struct TreeNode { /* private fields */ }Expand description
A tree node that contains a struct of TreeNodeType
plus the information needed to traverse the tree.
Implementations§
Source§impl TreeNode
impl TreeNode
Sourcepub fn perform_restructuredtext_transforms(&mut self)
pub fn perform_restructuredtext_transforms(&mut self)
Transforms self.data into a different type based on its current value.
This is where the recursion really kicks in.
Source§impl TreeNode
impl TreeNode
Sourcepub fn new(
data: TreeNodeType,
id: NodeId,
target_label: Option<Vec<String>>,
classes: Option<Vec<String>>,
) -> Self
pub fn new( data: TreeNodeType, id: NodeId, target_label: Option<Vec<String>>, classes: Option<Vec<String>>, ) -> Self
A TreeNode constructor.
Returns a shared (immutable) reference to the optional target label.
If the label is None, as is hasn’t been set, returns an
empty string slice instead.
Sourcepub fn push_child(&mut self, node: TreeNode) -> Result<(), TreeNode>
pub fn push_child(&mut self, node: TreeNode) -> Result<(), TreeNode>
Pushes a given child node the the end of self.children.
Sourcepub fn pop_child(&mut self) -> Option<Self>
pub fn pop_child(&mut self) -> Option<Self>
Removes the last child from own children and returns it in a Result, if successful.
If no whilc is found, returns Err(()).
Sourcepub fn append_children(&mut self, children: &mut Vec<TreeNode>)
pub fn append_children(&mut self, children: &mut Vec<TreeNode>)
Appends multiple children to self.children.
Retuns a shared reference to own target labels.
Sourcepub fn set_target_label(&mut self, label: Option<Vec<String>>)
pub fn set_target_label(&mut self, label: Option<Vec<String>>)
Sets the target label of the node to given Option<Vec<String>>.
Optionally returns a shared reference to vector containing child nodes.
Sourcepub fn mut_children(&mut self) -> &mut Option<Vec<TreeNode>>
pub fn mut_children(&mut self) -> &mut Option<Vec<TreeNode>>
Optionally returns a mutable reference to vector containing child nodes.
Sourcepub fn child_is_allowed(&self, node_data: &TreeNodeType) -> bool
pub fn child_is_allowed(&self, node_data: &TreeNodeType) -> bool
Checks whether a node is allowed to be inserted into another node.
Returns a shared reference to a child node of a given index. Panics, if the child does not exist.
Sourcepub fn mut_child(&mut self, index: usize) -> Option<&mut Self>
pub fn mut_child(&mut self, index: usize) -> Option<&mut Self>
Returns a mutable reference to a child node of a given index. Panics, if the child does not exist.
For retrieving an immutable reference to the data type of a node.
Sourcepub fn mut_data(&mut self) -> &mut TreeNodeType
pub fn mut_data(&mut self) -> &mut TreeNodeType
For retrieving a mutable reference to the data type of a node.