pub enum RedTree<'a, L: Language> {
Node(RedNode<'a, L>),
Leaf(RedLeaf<L>),
}Expand description
A red tree element with absolute position information.
Red trees are the “red” side of the red-green tree architecture. They are lazily computed from green trees and include absolute byte offsets in the source code.
Variants§
Implementations§
Source§impl<'a, L: Language> RedTree<'a, L>
impl<'a, L: Language> RedTree<'a, L>
Sourcepub fn span(&self) -> Range<usize>
pub fn span(&self) -> Range<usize>
Returns the absolute byte span of this red tree element.
The span includes the start and end offsets in the source text.
Sourcepub fn kind<T>(&self) -> T
pub fn kind<T>(&self) -> T
Returns the kind of this red tree element.
§Type Parameters
T- A type that can be converted from both node and token kinds.
Sourcepub fn text<'s, S: Source + ?Sized>(&self, source: &'s S) -> Cow<'s, str>
pub fn text<'s, S: Source + ?Sized>(&self, source: &'s S) -> Cow<'s, str>
Returns the text content of this red tree element from the source.
§Arguments
source- The source text provider.
Sourcepub fn children(&self) -> RedChildren<'a, L> ⓘ
pub fn children(&self) -> RedChildren<'a, L> ⓘ
Returns an iterator over the child elements if this is a node.
Returns an empty iterator if this is a token.
Trait Implementations§
impl<'a, L: Language> Copy for RedTree<'a, L>
impl<'a, L: Language> Eq for RedTree<'a, L>
Auto Trait Implementations§
impl<'a, L> Freeze for RedTree<'a, L>
impl<'a, L> RefUnwindSafe for RedTree<'a, L>
impl<'a, L> Send for RedTree<'a, L>
impl<'a, L> Sync for RedTree<'a, L>
impl<'a, L> Unpin for RedTree<'a, L>
impl<'a, L> UnsafeUnpin for RedTree<'a, L>
impl<'a, L> UnwindSafe for RedTree<'a, L>where
<L as Language>::TokenType: UnwindSafe + RefUnwindSafe,
<L as Language>::ElementType: 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