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>

§

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<Vector<'a>> for Vector<'a>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.