Skip to main content

CstRef

Struct CstRef 

Source
pub struct CstRef<'a, 'src> { /* private fields */ }
Expand description

A borrowed CST: the source, the arena and the syntax diagnostics.

Implementations§

Source§

impl<'a, 'src> CstRef<'a, 'src>

Source

pub fn source(&self) -> &'src str

The source.

Source

pub fn root(&self) -> Option<SyntaxNode<'a, 'src>>

The root node (None only for a source over u32::MAX bytes, which is rejected with crate::code::SOURCE_TOO_LONG).

Source

pub fn nodes(&self) -> &'a [Node]

The whole arena, in pre-order.

Source

pub fn diagnostics(&self) -> &'a [Diagnostic]

The syntax errors, in source order of detection.

Source

pub fn has_errors(&self) -> bool

Whether any syntax error was reported.

Source

pub fn tokens( &self, ) -> impl Iterator<Item = SyntaxNode<'a, 'src>> + use<'a, 'src>

The tokens (leaves), in source order.

Source

pub fn to_model(&self) -> Parsed<'src>

Lowers the CST to the data model and validates it (spans included); with a syntax error, no model and the syntax diagnostics.

Trait Implementations§

Source§

impl<'a, 'src> Clone for CstRef<'a, 'src>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, 'src> Copy for CstRef<'a, 'src>

Source§

impl<'a, 'src> Debug for CstRef<'a, 'src>

Source§

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

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

impl Display for CstRef<'_, '_>

Source§

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

Writes the tokens’ text in order, which is the source.

Auto Trait Implementations§

§

impl<'a, 'src> Freeze for CstRef<'a, 'src>

§

impl<'a, 'src> RefUnwindSafe for CstRef<'a, 'src>

§

impl<'a, 'src> Send for CstRef<'a, 'src>

§

impl<'a, 'src> Sync for CstRef<'a, 'src>

§

impl<'a, 'src> Unpin for CstRef<'a, 'src>

§

impl<'a, 'src> UnsafeUnpin for CstRef<'a, 'src>

§

impl<'a, 'src> UnwindSafe for CstRef<'a, 'src>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.