Enum Regex

Source
pub enum Regex<T> {
Show 14 variants Begin, End, Satisfy(Rc<dyn Fn(&T) -> bool>), NotSatisfy(Rc<dyn Fn(&T) -> bool>), Concat(Rc<Regex<T>>, Rc<Regex<T>>), Group(Rc<Regex<T>>), NamedGroup(String, Rc<Regex<T>>), NonCapturingGroup(Rc<Regex<T>>), Or(Rc<Regex<T>>, Rc<Regex<T>>), ZeroOrOne(Rc<Regex<T>>, bool), Repeat0(Rc<Regex<T>>, bool), Repeat1(Rc<Regex<T>>, bool), RepeatN(Rc<Regex<T>>, usize), RepeatMinMax(Rc<Regex<T>>, usize, Option<usize>, bool),
}

Variants§

§

Begin

Like a ‘^’ in ragex. Regex that matches the beginning of the input.

§

End

Like a ‘$’ in ragex. Regex that matches the end of the input.

§

Satisfy(Rc<dyn Fn(&T) -> bool>)

Like a [character class] in regex. Regex that matches any values that satisfy the given predicate.

§

NotSatisfy(Rc<dyn Fn(&T) -> bool>)

Like a [^character class] in regex. Regex that matches any values that not satisfy the given predicate.

§

Concat(Rc<Regex<T>>, Rc<Regex<T>>)

Like a RS in regex. Concatenate two regex.

§

Group(Rc<Regex<T>>)

Like a (R) in regex. Numbered capturing group (submatch).

§

NamedGroup(String, Rc<Regex<T>>)

Like a (?<name>R) in regex. Numbered capturing group (submatch).

§

NonCapturingGroup(Rc<Regex<T>>)

Like a (?:R) in regex. Numbered non-capturing group.

§

Or(Rc<Regex<T>>, Rc<Regex<T>>)

Like a R|S in regex. Regex alternation.

§

ZeroOrOne(Rc<Regex<T>>, bool)

Like a ?, ?? in regex. Regex zero or one.

§

Repeat0(Rc<Regex<T>>, bool)

Like a *, *? in regex. Regex zero or one.

§

Repeat1(Rc<Regex<T>>, bool)

Like a +, +? in regex. Regex one or more.

§

RepeatN(Rc<Regex<T>>, usize)

Like a {n} in regex. Exactly N-times.

§

RepeatMinMax(Rc<Regex<T>>, usize, Option<usize>, bool)

Like a {n,m}, {n,m}? or {n,}, {n,}? in regex. n or n+1 or .. m times.

Implementations§

Source§

impl<T: 'static> Regex<T>

Source

pub fn begin() -> Self

Like a ^ in regex. Build regex that matches the begging of the input.

Source

pub fn end() -> Self

Like a $ in regex. Build regex that matches the end of the input.

Source

pub fn satisfy(f: impl Fn(&T) -> bool + 'static) -> Self

Like a [character class] in regex. Build regex that matches any value that satisfies the given predicate.

Source

pub fn not_satisfy(f: impl Fn(&T) -> bool + 'static) -> Self

Like a [^character class] in regex. Build regex that matches any value that not satisfies the given predicate.

Source

pub fn any() -> Self

Like a . in regex. Build regex that matches any value.

Source

pub fn zero_or_one(reg: Self, greedy: bool) -> Self

Like a ?, ?? in regex. Build regex that matches underlying regex zero or one times.

Source

pub fn repeat1(reg: Self, greedy: bool) -> Self

Like a +, +? in regex. Build regex that matches underlying regex one or more.

Source

pub fn repeat0(reg: Self, greedy: bool) -> Self

Like a *, *? in regex. Build regex that matches underlying regex zero or more.

Source

pub fn repeat_n(reg: Self, n: usize) -> Self

Like a {n} in regex. Build regex that matches underlying regex N-times.

Source

pub fn repeat_n_or_more(reg: Self, n: usize, greedy: bool) -> Self

Like a {n,}, {n,}? in regex. Build regex that matches underlying regex N-times or more.

Source

pub fn repeat_min_max(reg: Self, n: usize, m: usize, greedy: bool) -> Self

Like a {n,m}, {n,m}? in regex. Build regex that matches underlying regex n or n + 1 or … or m times.

Source

pub fn concat(r: Self, s: Self) -> Self

Like a RS in regex. Build regex that R followd by S.

Source

pub fn or(r: Self, s: Self) -> Self

Like a R|S in regex. Build regex that matches R or S.

Source

pub fn group(r: Self) -> Self

Like a (R) in regex. Numbered capturing group (submatch).

Source

pub fn non_capturing_group(r: Self) -> Self

Like a (?:R) in regex. Numbered capturing group (submatch).

Source

pub fn named_group(name: &str, r: Self) -> Self

Like a (?P<name>R) in regex. Numbered capturing group (submatch).

Source

pub fn is(value: T) -> Self
where T: PartialEq + 'static,

Build regex that matches given value.

Source

pub fn seq(values: &[T]) -> Self
where T: PartialEq + Clone + 'static,

Build regex that matches given value sequence.

Source

pub fn compile(self) -> impl CompiledRegex<T>

Trait Implementations§

Source§

impl<T: Clone> Clone for Regex<T>

Source§

fn clone(&self) -> Regex<T>

Returns a duplicate 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<T> Debug for Regex<T>

Source§

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

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

impl<T> Display for Regex<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Regex<T>

§

impl<T> !RefUnwindSafe for Regex<T>

§

impl<T> !Send for Regex<T>

§

impl<T> !Sync for Regex<T>

§

impl<T> Unpin for Regex<T>

§

impl<T> !UnwindSafe for Regex<T>

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.