Skip to main content

Node

Enum Node 

Source
pub enum Node {
    List {
        kind: ListKind,
        items: Vec<Item>,
    },
    Atom(String),
    Str(String),
    Prefixed {
        prefix: String,
        inner: Box<Node>,
    },
}

Variants§

§

List

Fields

§items: Vec<Item>
§

Atom(String)

Symbols, numbers, booleans (#t/#f), chars (#\x), keywords (#:k), #{...}# extended symbols, and .

§

Str(String)

Raw string literal INCLUDING surrounding quotes, escapes as written.

§

Prefixed

prefix is one of: ’ , ,@ #' # #, #,@ #~ #$ #$@ #+ (gexp syntax).

Fields

§prefix: String
§inner: Box<Node>

Implementations§

Source§

impl Node

Source

pub fn to_source(&self) -> String

Verbatim source text of this node.

Source

pub fn head_symbol(&self) -> Option<&str>

For a list, the text of its first data child if that child is an Atom.

Source

pub fn as_symbol(&self) -> Option<&str>

Symbol text, drilling through 'sym and (quote sym).

Source

pub fn as_string_lit(&self) -> Option<String>

Unescaped contents of a string literal.

Source

pub fn list_nodes(&self) -> impl Iterator<Item = &Node>

Data children of a list, trivia skipped. Empty for non-lists.

Source§

impl Node

Source

pub fn data_len(&self) -> usize

Number of data children (trivia excluded).

Source

pub fn data_child(&self, data_index: usize) -> Option<&Node>

Source

pub fn data_child_mut(&mut self, data_index: usize) -> Option<&mut Node>

Source

pub fn position_of<F: Fn(&Node) -> bool>(&self, pred: F) -> Option<usize>

Data index of the first child matching PRED.

Source

pub fn insert_child(&mut self, data_index: usize, node: Node)

Insert NODE before the DATA_INDEX-th data child; trivia stays attached to its original neighbor. Out-of-range appends.

Source

pub fn push_child(&mut self, node: Node)

Insert NODE after the last data child (before trailing trivia/close).

Source

pub fn replace_child(&mut self, data_index: usize, node: Node) -> bool

Source

pub fn remove_child( &mut self, data_index: usize, take_leading_trivia: bool, ) -> Option<Node>

Remove the DATA_INDEX-th data child. With TAKE_LEADING_TRIVIA, the comments and blanks between the previous data child and this one go with it; otherwise only directly adjacent whitespace is dropped.

Source§

impl Node

Source

pub fn to_pretty(&self, indent: usize) -> String

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

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 Debug for Node

Source§

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

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

impl Display for Node

Source§

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

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

impl Eq for Node

Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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