pub struct SyntaxToken { /* private fields */ }Expand description
A leaf token in the syntax tree.
Represents a contiguous span of source text with a known kind.
Implementations§
Source§impl SyntaxToken
impl SyntaxToken
Sourcepub fn new(kind: SyntaxKind, range: TextRange) -> Self
pub fn new(kind: SyntaxKind, range: TextRange) -> Self
Creates a new token with the given kind and range.
Sourcepub fn kind(&self) -> SyntaxKind
pub fn kind(&self) -> SyntaxKind
The kind of this token.
Sourcepub fn is_missing(&self) -> bool
pub fn is_missing(&self) -> bool
Whether this token is missing from the source (zero-length placeholder).
A missing token marks the exact offset where the absent element would be inserted — the edit API’s insertion anchor (see the module docs). Placeholders are only ever replaced by a real token, never extended in place.
Sourcepub fn text<'a>(&self, source: &'a str) -> &'a str
pub fn text<'a>(&self, source: &'a str) -> &'a str
Extract the corresponding text slice from source.
Sourcepub fn pretty_fmt(&self, src: &str, indent: usize, out: &mut String)
pub fn pretty_fmt(&self, src: &str, indent: usize, out: &mut String)
Write a pretty-printed token line.
A zero-length (missing placeholder) token renders as <missing>
instead of an empty text literal.
Trait Implementations§
Source§impl Clone for SyntaxToken
impl Clone for SyntaxToken
Source§fn clone(&self) -> SyntaxToken
fn clone(&self) -> SyntaxToken
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SyntaxToken
impl Debug for SyntaxToken
impl Eq for SyntaxToken
Source§impl PartialEq for SyntaxToken
impl PartialEq for SyntaxToken
impl StructuralPartialEq for SyntaxToken
Auto Trait Implementations§
impl Freeze for SyntaxToken
impl RefUnwindSafe for SyntaxToken
impl Send for SyntaxToken
impl Sync for SyntaxToken
impl Unpin for SyntaxToken
impl UnsafeUnpin for SyntaxToken
impl UnwindSafe for SyntaxToken
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