pub struct RegexConstraint { /* private fields */ }Expand description
Constrains generation to strings that match a regular expression.
Uses a minimal NFA engine (no external crate). Supported syntax:
- Literals,
.(any char),*,+,? - Alternation
| - Grouping
(...) - Character classes
[abc],[a-z],[^x] - Escapes:
\d,\D,\w,\W,\s,\S,\n,\r,\t
Implementations§
Source§impl RegexConstraint
impl RegexConstraint
Sourcepub fn new(pattern: &str) -> Result<Self, ConstraintError>
pub fn new(pattern: &str) -> Result<Self, ConstraintError>
Build a new constraint from pattern.
Sourcepub fn current_partial(&self) -> &str
pub fn current_partial(&self) -> &str
The text matched so far.
Sourcepub fn char_is_valid(&self, ch: char) -> bool
pub fn char_is_valid(&self, ch: char) -> bool
Check whether character ch would keep the NFA in a live (non-dead) state.
Trait Implementations§
Source§impl TokenConstraint for RegexConstraint
impl TokenConstraint for RegexConstraint
Auto Trait Implementations§
impl Freeze for RegexConstraint
impl RefUnwindSafe for RegexConstraint
impl Send for RegexConstraint
impl Sync for RegexConstraint
impl Unpin for RegexConstraint
impl UnsafeUnpin for RegexConstraint
impl UnwindSafe for RegexConstraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more