Enum Regex

Source
pub enum Regex {
    SingleCharacter {
        value: u8,
    },
    Union {
        options: Vec<Regex>,
    },
    Concat {
        parts: Vec<Regex>,
    },
    Star {
        repeated_pattern: Box<Regex>,
    },
}
Expand description

A regular-expression pattern over raw bytes.

In practice, you won’t need to create instances of this type directly. Check out the Regex API and the high-level factory methods it offers.

Variants§

§

SingleCharacter

Only matches a single hardcoded byte.

Fields

§value: u8

The matching byte.

§

Union

Matches each one of the specified patterns.

Fields

§options: Vec<Regex>

The possible matching patterns.

§

Concat

Matches a concatenation of the specified patterns.

Fields

§parts: Vec<Regex>

The concatenated patterns.

§

Star

Matches a concatenation of zero or more repetitions of the specified pattern.

Fields

§repeated_pattern: Box<Regex>

The repeated pattern.

Implementations§

Source§

impl Regex

Source

pub fn single_char(value: char) -> Regex

Creates a pattern that only matches the specified character.

§Panics

If the character is not ASCII (cannot be represented by a single byte).

Source

pub fn union(options: Vec<Regex>) -> Regex

Creates a pattern that matches each of the specified patterns.

Source

pub fn concat(parts: Vec<Regex>) -> Regex

Creates a pattern that matches a concatenation of the specified patterns.

Source

pub fn star_from(repeated_pattern: Regex) -> Regex

Creates a pattern that matches zero or more repetitions of the specified pattern.

Source

pub fn plus_from(repeated_pattern: Regex) -> Regex

Creates a pattern that matches one or more repetitions of the specified pattern.

Source

pub fn white_space() -> Regex

Creates a pattern that matches a single white-space character.

Source

pub fn constant_string(string: &str) -> Regex

Creates a pattern that matches a hard-coded sequence of characters.

Source

pub fn character_range(start: char, end: char) -> Regex

Creates a pattern that matches any single character between the specified couple of characters (inclusive).

Source

pub fn optional(option: Regex) -> Regex

Creates a pattern that matches the specified pattern, and an empty sequence of bytes.

Source

pub fn epsilon() -> Regex

Creates a pattern that only matches an empty sequence of characters.

Trait Implementations§

Source§

impl Clone for Regex

Source§

fn clone(&self) -> Regex

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

Auto Trait Implementations§

§

impl Freeze for Regex

§

impl RefUnwindSafe for Regex

§

impl Send for Regex

§

impl Sync for Regex

§

impl Unpin for Regex

§

impl UnwindSafe for Regex

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 = 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.