pub struct GreenNode<K: Copy> {
pub kind: K,
pub children: Vec<GreenTree<K>>,
pub length: usize,
}Expand description
A green node that contains child elements without parent pointers.
Green nodes represent kind tree nodes with their structural information but without position data or parent references. This design makes them immutable and shareable across different parse trees.
Fields§
§kind: KThe node kind/category (e.g., expression, statement, declaration)
children: Vec<GreenTree<K>>The child elements of this node
length: usizeThe total byte length of this node and all its children
Implementations§
Source§impl<K: Copy> GreenNode<K>
impl<K: Copy> GreenNode<K>
Sourcepub fn replace_range(
&self,
replace_start: usize,
replace_end: usize,
new_children: Vec<GreenTree<K>>,
) -> Arc<Self>
pub fn replace_range( &self, replace_start: usize, replace_end: usize, new_children: Vec<GreenTree<K>>, ) -> Arc<Self>
Replaces a range of child elements with new children.
This method is essential for incremental parsing, allowing efficient updates to kind trees by replacing only the changed portions.
§Arguments
replace_start- The starting index of the range to replace (inclusive)replace_end- The ending index of the range to replace (exclusive)new_children- The new child elements to insert
§Returns
A new Arc<GreenNode<K>> with the specified children replaced
§Panics
Panics if the indices are out of bounds or if replace_start > replace_end
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for GreenNode<K>where
K: Freeze,
impl<K> RefUnwindSafe for GreenNode<K>where
K: RefUnwindSafe,
impl<K> Send for GreenNode<K>
impl<K> Sync for GreenNode<K>
impl<K> Unpin for GreenNode<K>where
K: Unpin,
impl<K> UnwindSafe for GreenNode<K>where
K: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more