Struct Tree

Source
pub struct Tree<T> { /* private fields */ }
Expand description

The syntax tree struct.

Implementations§

Source§

impl<T> Tree<T>
where T: Eq + Hash,

Source

pub fn new(string: &str, listener: Option<Listener<T>>) -> Tree<T>

Create new tree.

Source

pub fn set(&mut self, start_idx: usize, end_idx: usize, info: T)

Set syntax/format info for the passed range. The range is the passed start index (inclusive) to the passed end index (exclusive).

Source

pub fn unset(&mut self, start_idx: usize, end_idx: usize, info: T)

Unset the passed syntax/format info for the passed range. The range is the passed start index (inclusive) to the passed end index (exclusive).

Source

pub fn insert(&mut self, idx: usize, ch: char)

Insert a char in the underlying text.

Source

pub fn insert_str(&mut self, idx: usize, string: &str)

Insert a string in the underlying text.

Source

pub fn push(&mut self, ch: char)

Push a char to the underlying text.

Source

pub fn push_str(&mut self, string: &str)

Push a string to the underlying text.

Source

pub fn length(&self) -> usize

Get the length of the underlying text.

Source

pub fn remove(&mut self, idx: usize, count: usize)

Remove a count of characters from the underlying text starting at idx.

Source

pub fn pop(&mut self)

Pop a char from the underlying text.

Source

pub fn clear(&mut self, keep_formats: bool)

Clear the underlying text. Specify whether you want the tree to keep the formats on the root node.

Source

pub fn get_root(&self) -> &Node<T>

Get the root node.

Source

pub fn pre_order_iter(&self) -> PreOrder<'_, T>

Get a depth first pre order iterator.

Source

pub fn leaf_iter(&self) -> impl Iterator<Item = Item<'_, T>>

Get a leaf iterator.

Trait Implementations§

Source§

impl<T> Debug for Tree<T>
where T: Ord + Hash + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Tree<T>

§

impl<T> !RefUnwindSafe for Tree<T>

§

impl<T> !Send for Tree<T>

§

impl<T> !Sync for Tree<T>

§

impl<T> Unpin for Tree<T>

§

impl<T> !UnwindSafe for Tree<T>

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.