Enum regex_syntax::ast::Ast

source ·
pub enum Ast {
    Empty(Span),
    Flags(SetFlags),
    Literal(Literal),
    Dot(Span),
    Assertion(Assertion),
    Class(Class),
    Repetition(Repetition),
    Group(Group),
    Alternation(Alternation),
    Concat(Concat),
}
Expand description

An abstract syntax tree for a single regular expression.

An Ast’s fmt::Display implementation uses constant stack space and heap space proportional to the size of the Ast.

This type defines its own destructor that uses constant stack space and heap space proportional to the size of the Ast.

Variants§

§

Empty(Span)

An empty regex that matches everything.

§

Flags(SetFlags)

A set of flags, e.g., (?is).

§

Literal(Literal)

A single character literal, which includes escape sequences.

§

Dot(Span)

The “any character” class.

§

Assertion(Assertion)

A single zero-width assertion.

§

Class(Class)

A single character class. This includes all forms of character classes except for .. e.g., \d, \pN, [a-z] and [[:alpha:]].

§

Repetition(Repetition)

A repetition operator applied to an arbitrary regular expression.

§

Group(Group)

A grouped regular expression.

§

Alternation(Alternation)

An alternation of regular expressions.

§

Concat(Concat)

A concatenation of regular expressions.

Implementations§

source§

impl Ast

source

pub fn span(&self) -> &Span

Return the span of this abstract syntax tree.

source

pub fn is_empty(&self) -> bool

Return true if and only if this Ast is empty.

Trait Implementations§

source§

impl Clone for Ast

source§

fn clone(&self) -> Ast

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

source§

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

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

impl Display for Ast

Print a display representation of this Ast.

This does not preserve any of the original whitespace formatting that may have originally been present in the concrete syntax from which this Ast was generated.

This implementation uses constant stack space and heap space proportional to the size of the Ast.

source§

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

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

impl Drop for Ast

A custom Drop impl is used for Ast such that it uses constant stack space but heap space proportional to the depth of the Ast.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl PartialEq<Ast> for Ast

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Ast

source§

impl StructuralEq for Ast

source§

impl StructuralPartialEq for Ast

Auto Trait Implementations§

§

impl RefUnwindSafe for Ast

§

impl Send for Ast

§

impl Sync for Ast

§

impl Unpin for Ast

§

impl UnwindSafe for Ast

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.