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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so 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"));