Struct human_regex::HumanRegex

source ·
pub struct HumanRegex(pub String);
Expand description

The HumanRegex struct which maintains and updates the regex string. For most use cases it will never be necessary to instantiate this directly.

Tuple Fields§

§0: String

Implementations§

source§

impl HumanRegex

source

pub fn to_regex(&self) -> Regex

Convert to a rust Regex

source

pub fn lazy(&self) -> HumanRegex

Add a lazy modifier

Trait Implementations§

source§

impl Add<HumanRegex> for HumanRegex

let regex_string = human_regex::zero_or_one("chris") + human_regex::text("mccomb");
assert!(regex_string.to_regex().is_match("mccomb"));
assert!(regex_string.to_regex().is_match("chrismccomb"));
§

type Output = HumanRegex

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl BitAnd<HumanRegex> for HumanRegex

Allows the use of & as a syntax sugar for and

use human_regex::{text, or, within};
let regex_string = (within('a'..='y') & or(&['x','y','z']));
println!("{}", regex_string);
assert!(regex_string.to_regex().is_match("x"));
assert!(regex_string.to_regex().is_match("y"));
assert!(!regex_string.to_regex().is_match("z"));
§

type Output = HumanRegex

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl Debug for HumanRegex

source§

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

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

impl Display for HumanRegex

source§

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

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

impl From<HumanRegex> for String

source§

fn from(hr: HumanRegex) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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