Struct Vector

Source
pub struct Vector<'a> {
    pub leaves: Vec<VectorLeaf<'a>>,
    pub source_text: &'a str,
}
Expand description

A vector that allows for linear traversal through the leafs of an AST.

This representation of the tree leaves is much more convenient for things like dynamic programming, and provides useful for formatting.

Fields§

§leaves: Vec<VectorLeaf<'a>>

The leaves of the AST, build with an in-order traversal

§source_text: &'a str

The full source text that the AST refers to

Implementations§

Source§

impl<'a> Vector<'a>

Source

pub fn from_ts_tree(tree: &'a TSTree, text: &'a str) -> Self

Create a DiffVector from a tree_sitter tree

This method calls a helper function that does an in-order traversal of the tree and adds leaf nodes to a vector

Source

pub fn len(&self) -> usize

Return the number of nodes in the diff vector

Source

pub fn is_empty(&self) -> bool

Return whether there are any leaves in the diff vector.

Trait Implementations§

Source§

impl<'a> Debug for Vector<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Vector<'a>> for Vec<Entry<'a>>

Source§

fn from(ast_vector: &'a Vector<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Index<usize> for Vector<'a>

Source§

type Output = VectorLeaf<'a>

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> PartialEq for Vector<'a>

Source§

fn eq(&self, other: &Vector<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'a> Freeze for Vector<'a>

§

impl<'a> RefUnwindSafe for Vector<'a>

§

impl<'a> Send for Vector<'a>

§

impl<'a> Sync for Vector<'a>

§

impl<'a> Unpin for Vector<'a>

§

impl<'a> UnwindSafe for Vector<'a>

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.