pub trait Condition: AsRegex + Sized {
    // Provided methods
    fn and(self, other: impl AsRegex) -> Regex { ... }
    fn or(self, other: impl AsRegex) -> Regex { ... }
    fn optionally(self) -> Regex { ... }
}
Expand description

A trait, which allows to chain regex statements with conditions. Import this, if you want to use the and, or and optionally methods and chain statements.

Provided Methods§

source

fn and(self, other: impl AsRegex) -> Regex

Returns the regex, which chains the two given statements with an and condition.

source

fn or(self, other: impl AsRegex) -> Regex

Returns the regex, which chains the two given statements with an or condition.

source

fn optionally(self) -> Regex

Returns the regex, which sets the given statement to optional.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Condition for Regex

Implementors§

source§

impl<'a> Condition for Input<'a>

Returns a Regex, which chains the 2 given regexes with an and operator.

§Example

use magic_regexp::{create_reg_exp, Condition, Exactly, Digit, LetterLowercase};

let regex = create_reg_exp(Exactly(Digit).or(Exactly(LetterLowercase))).unwrap();
assert!(regex.is_match("1"));
assert!(regex.is_match("a"));
assert!(!regex.is_match("A"));
assert!(!regex.is_match("12"));
assert!(!regex.is_match("1a"));
assert!(regex.is_match("1 a"));