jsonc_parser::ast

Enum Node

Source
pub enum Node<'a, 'b> {
    StringLit(&'b StringLit<'a>),
    NumberLit(&'b NumberLit<'a>),
    BooleanLit(&'b BooleanLit),
    Object(&'b Object<'a>),
    ObjectProp(&'b ObjectProp<'a>),
    Array(&'b Array<'a>),
    NullKeyword(&'b NullKeyword),
    WordLit(&'b WordLit<'a>),
}
Expand description

Node that can appear in the AST.

Variants§

§

StringLit(&'b StringLit<'a>)

§

NumberLit(&'b NumberLit<'a>)

§

BooleanLit(&'b BooleanLit)

§

Object(&'b Object<'a>)

§

ObjectProp(&'b ObjectProp<'a>)

§

Array(&'b Array<'a>)

§

NullKeyword(&'b NullKeyword)

§

WordLit(&'b WordLit<'a>)

Implementations§

Source§

impl<'a, 'b> Node<'a, 'b>

Source

pub fn kind(&self) -> NodeKind

Gets the node kind.

Source

pub fn as_string_lit(&self) -> Option<&'b StringLit<'a>>

Source

pub fn as_number_lit(&self) -> Option<&'b NumberLit<'a>>

Source

pub fn as_boolean_lit(&self) -> Option<&'b BooleanLit>

Source

pub fn as_object(&self) -> Option<&'b Object<'a>>

Source

pub fn as_object_prop(&self) -> Option<&'b ObjectProp<'a>>

Source

pub fn as_array(&self) -> Option<&'b Array<'a>>

Source

pub fn as_null_keyword(&self) -> Option<&'b NullKeyword>

Source

pub fn as_word_lit(&self) -> Option<&'b WordLit<'a>>

Trait Implementations§

Source§

impl<'a, 'b> Clone for Node<'a, 'b>

Source§

fn clone(&self) -> Node<'a, 'b>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, 'b> Debug for Node<'a, 'b>

Source§

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

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

impl<'a, 'b> From<&'b Array<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b Array<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b BooleanLit> for Node<'a, 'b>

Source§

fn from(node: &'b BooleanLit) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b NullKeyword> for Node<'a, 'b>

Source§

fn from(node: &'b NullKeyword) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b NumberLit<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b NumberLit<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b Object<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b Object<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b ObjectProp<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b ObjectProp<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b ObjectPropName<'a>> for Node<'a, 'b>

Source§

fn from(object_prop_name: &'b ObjectPropName<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b StringLit<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b StringLit<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b Value<'a>> for Node<'a, 'b>

Source§

fn from(value: &'b Value<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'b WordLit<'a>> for Node<'a, 'b>

Source§

fn from(node: &'b WordLit<'a>) -> Node<'a, 'b>

Converts to this type from the input type.
Source§

impl<'a, 'b> PartialEq for Node<'a, 'b>

Source§

fn eq(&self, other: &Node<'a, 'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> Ranged for Node<'a, 'b>

Source§

fn range(&self) -> Range

Gets the range.
Source§

fn start(&self) -> usize

Gets the byte index of the first character in the text.
Source§

fn end(&self) -> usize

Gets the byte index after the last character in the text.
Source§

fn text<'a>(&self, text: &'a str) -> &'a str

Gets the text from the provided string.
Source§

fn width(&self) -> usize

Gets the end byte index minus the start byte index of the range.
Source§

impl<'a, 'b> Copy for Node<'a, 'b>

Source§

impl<'a, 'b> StructuralPartialEq for Node<'a, 'b>

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for Node<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for Node<'a, 'b>

§

impl<'a, 'b> Send for Node<'a, 'b>

§

impl<'a, 'b> Sync for Node<'a, 'b>

§

impl<'a, 'b> Unpin for Node<'a, 'b>

§

impl<'a, 'b> UnwindSafe for Node<'a, 'b>

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, dst: *mut T)

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

Source§

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 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.