[][src]Trait rec::prelude::Element

pub trait Element: Add<Rec, Output = Rec> + BitOr<Rec, Output = Rec> + Debug + PartialEq<Rec> {
    fn to_regex(&self) -> String;
fn is_atom(&self) -> bool; fn alternate(&self, other: &dyn Element) -> Rec { ... }
fn concatenate(&self, other: &dyn Element) -> Rec { ... }
fn is_equal(&self, other: &dyn Element) -> bool { ... }
fn isolate(&self) -> String { ... }
fn group(&self) -> String { ... } }

An item that can be converted into a regular expression.

Required methods

fn to_regex(&self) -> String

Converts self to a regular expression compatible with regex.

fn is_atom(&self) -> bool

Returns if self is an Atom.

Loading content...

Provided methods

fn alternate(&self, other: &dyn Element) -> Rec

Creates a Rec consisting of the alternation of self and other.

Examples

use rec::{Class, prelude::*};

assert_eq!('a' + (Class::Digit | ('b' + Class::Whitespace)) + 'c', Rec::from(r"a(?:\d|b\s)c"));

fn concatenate(&self, other: &dyn Element) -> Rec

Creates a Rec consisting of the concatenation of self and other.

fn is_equal(&self, other: &dyn Element) -> bool

Returns if the regular expression of self is equal to that of other.

fn isolate(&self) -> String

Returns the regular expression of self such that it can be concatenated.

By default, returns to_regex. Should be overriden by Elements that require grouping.

fn group(&self) -> String

Returns the regular expression of self as a single Atom.

If grouping is needed, uses the non-capturing grouping mechanism.

Loading content...

Implementations on Foreign Types

impl Element for char[src]

impl<'_> Element for &'_ str[src]

impl Element for String[src]

Loading content...

Implementors

impl Element for Class[src]

impl Element for Rec[src]

impl Element for Ch[src]

Loading content...