TreeNode

Struct TreeNode 

Source
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

Source

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

Source

pub fn new( data: TreeNodeType, id: NodeId, target_label: Option<Vec<String>>, classes: Option<Vec<String>>, ) -> Self

A TreeNode constructor.

Source

pub fn id(&self) -> NodeId

Returns a copy of own id.

Source

pub fn shared_target_label(&self) -> &Option<Vec<String>>

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.

Source

pub fn push_child(&mut self, node: TreeNode) -> Result<(), TreeNode>

Pushes a given child node the the end of self.children.

Source

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(()).

Source

pub fn append_children(&mut self, children: &mut Vec<TreeNode>)

Appends multiple children to self.children.

Source

pub fn shared_target_labels(&self) -> &Option<Vec<String>>

Retuns a shared reference to own target labels.

Source

pub fn set_target_label(&mut self, label: Option<Vec<String>>)

Sets the target label of the node to given Option<Vec<String>>.

Source

pub fn shared_children(&self) -> &Option<Vec<TreeNode>>

Optionally returns a shared reference to vector containing child nodes.

Source

pub fn mut_children(&mut self) -> &mut Option<Vec<TreeNode>>

Optionally returns a mutable reference to vector containing child nodes.

Source

pub fn child_is_allowed(&self, node_data: &TreeNodeType) -> bool

Checks whether a node is allowed to be inserted into another node.

Source

pub fn shared_child(&self, index: usize) -> Option<&Self>

Returns a shared reference to a child node of a given index. Panics, if the child does not exist.

Source

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.

Source

pub fn shared_data(&self) -> &TreeNodeType

For retrieving an immutable reference to the data type of a node.

Source

pub fn mut_data(&mut self) -> &mut TreeNodeType

For retrieving a mutable reference to the data type of a node.

Trait Implementations§

Source§

impl Debug for TreeNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.