Trait magic_regexp::Condition
source · 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§
sourcefn and(self, other: impl AsRegex) -> Regex
fn and(self, other: impl AsRegex) -> Regex
Returns the regex, which chains the two given statements with an and
condition.
sourcefn or(self, other: impl AsRegex) -> Regex
fn or(self, other: impl AsRegex) -> Regex
Returns the regex, which chains the two given statements with an or
condition.
sourcefn optionally(self) -> Regex
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§
impl Condition for Regex
Implementors§
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"));