[−][src]Trait rec::prelude::Element
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
.
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 Element
s 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.
Implementations on Foreign Types
impl Element for char
[src]
fn to_regex(&self) -> String
[src]
use rec::{var, prelude::*}; assert_eq!('?' + var('a'), Rec::from(r"\?a*"));