Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 15 variants Empty, Char(char), Any, Class(bool, Vec<(char, char)>), Set(Box<ClassSet>), Property { kind: PropertyKind, negated: bool, }, Start, End, WordBoundary(bool), Group { index: Option<usize>, node: Box<Node>, }, Concat(Vec<Node>), Alt(Vec<Node>), Repeat { node: Box<Node>, min: u32, max: Option<u32>, greedy: bool, }, Backref(usize), Look { node: Box<Node>, ahead: bool, negated: bool, },
}
Expand description

One node of the pattern’s syntax tree.

Variants§

§

Empty

Matches nothing: the identity of a concatenation.

§

Char(char)

A literal character.

§

Any

.

§

Class(bool, Vec<(char, char)>)

[...], or a bare \d-style escape. The flag says whether the set is inverted.

§

Set(Box<ClassSet>)

A v-mode character class: sets, nesting, &&, -- and \q{…} strings.

§

Property

\p{Name} / \P{Name}: a Unicode property escape.

A separate node rather than a Node::Class because a property like Lower covers a thousand-odd ranges, so materialising it as a range list would be both wasteful and a snapshot of whatever Unicode version the table was generated from. The matcher asks the property directly instead.

Fields

§kind: PropertyKind

Which property.

§negated: bool

\P{…} rather than \p{…}.

§

Start

^

§

End

$

§

WordBoundary(bool)

\b when true, \B when false.

§

Group

(…) with a capture index, or (?:…) with none.

Fields

§index: Option<usize>

Which capture register the group fills; None for (?:…).

§node: Box<Node>

The group’s contents.

§

Concat(Vec<Node>)

A sequence.

§

Alt(Vec<Node>)

a|b

§

Repeat

*, +, ?, {n,m}, greedy or lazy.

Fields

§node: Box<Node>

What is repeated.

§min: u32

Fewest repetitions.

§max: Option<u32>

Most repetitions, or None for unbounded.

§greedy: bool

Greedy matches try one more repetition first; lazy ones try the rest first.

§

Backref(usize)

\1

§

Look

(?=…) / (?!…).

Fields

§node: Box<Node>

The assertion’s contents.

§ahead: bool

Always true: lookbehind is not implemented.

§negated: bool

(?!) rather than (?=).

Implementations§

Source§

impl Node

Source

pub fn nullable(&self) -> bool

Whether the node can match the empty string.

The regexp-aware String methods need this to avoid looping forever on a pattern like /(?:)/g, which matches at every position without advancing.

Trait Implementations§

Source§

impl Clone for Node

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move 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, 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.