Enum generator_combinator::Generator [−][src]
The building block of generator-combinators.
A Generator
can be constructed from strings, chars, and slices:
use generator_combinator::Generator; let foo = Generator::from("foo"); // generates the string `foo` let dot = Generator::from('.'); // generates the string `.` let countries = Generator::from(&["US", "FR", "NZ", "CH"][..]); // generates strings `US`, `FR`, `NZ`, and `CH`.
Individual Generator
s can be combined as sequences with +
, as variants with |
, and with repetition with * usize
and * (usize, usize)
:
use generator_combinator::Generator; let foo = Generator::from("foo"); let bar = Generator::from("bar"); let foobar = foo.clone() + bar.clone(); // generates `foobar` let foo_or_bar = foo.clone() | bar.clone(); // generates `foo`, `bar` let foo_or_bar_x2 = foo_or_bar.clone() * 2; // generates `foofoo`, `foobar`, `barfoo`, `barbar` let foo_x2_to_x4 = foo.clone() * (2, 4); // generates `foofoo`, `foofoofoo`, `foofoofoofoo`
Variants
Lowercase letters (a-z)
Uppercase letters (A-Z)
Base-10 digits (0-9)
Lowercase letters and digits (a-z0-9)
Uppercase letters and digits (A-Z0-9)
Uppercase hexadecimal values (0-9A-F)
Lowercase hexadecimal values (0-9a-f)
Char(char)
Generates a char
literal.
Str(String)
Generates a String
literal.
Note that this is not a character class.
Str("foo".into())
generates the exact string "foo"
A choice between two or more patterns
As a regex, this would be, eg, (a|b|c)?
A pattern repeated exactly n times. This is the same as RepeatedMN
(a, n, n)
As a regex, this would be a{n}
A pattern repeated at least m times, as many as n times.
As a regex, this would be a{m,n}
Two or more sequential patterns.
As a regex, this would be, eg, abc
Implementations
impl Generator
[src]
pub fn regex(&self) -> String
[src]
Create a regular expression that represents the patterns generated.
The result here is currently best-guess. It’s not guaranteed valid, correct, idiomatic, etc.
pub fn len(&self) -> u128
[src]
The number of possible patterns represented.
pub fn generate_exact(&self, num: u128) -> String
[src]
pub fn optional(self) -> Self
[src]
Makes this Generator
optional.
As a regex, this is the ?
operator.
pub fn values(&self) -> Iter<'_>ⓘ
[src]
Provides an iterator across all possible values for this Generator
.
pub fn transform(self, f: fn(_: String) -> String) -> Self
[src]
Trait Implementations
impl Add<Generator> for Generator
[src]
Add operator for exact repetitions.
The following expressions are equivalent:
use generator_combinator::Generator; let foostr = Generator::from("foofoo"); let foomul = Generator::from("foo") * 2; let fooadd = Generator::from("foo") + Generator::from("foo");
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
impl AddAssign<Generator> for Generator
[src]
fn add_assign(&mut self, rhs: Self)
[src]
impl BitOr<Generator> for Generator
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self::Output
[src]
impl BitOrAssign<Generator> for Generator
[src]
fn bitor_assign(&mut self, rhs: Self)
[src]
impl Clone for Generator
[src]
impl Debug for Generator
[src]
impl<T> From<&'_ [T]> for Generator where
T: AsRef<str> + Display,
[src]
T: AsRef<str> + Display,
impl From<&'_ str> for Generator
[src]
impl From<char> for Generator
[src]
impl Mul<(usize, usize)> for Generator
[src]
Mul operator for repetitions between m
and n
(inclusive)
use generator_combinator::Generator; let foo_two_to_five_times = Generator::from("foo") * (2,5);
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: (usize, usize)) -> Self::Output
[src]
impl Mul<usize> for Generator
[src]
Mul operator for exact repetitions.
The following expressions are equivalent:
use generator_combinator::Generator; let foostr = Generator::from("foofoo"); let foomul = Generator::from("foo") * 2; let fooadd = Generator::from("foo") + Generator::from("foo");
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: usize) -> Self::Output
[src]
impl MulAssign<(usize, usize)> for Generator
[src]
impl MulAssign<usize> for Generator
[src]
fn mul_assign(&mut self, rhs: usize)
[src]
impl PartialEq<Generator> for Generator
[src]
impl StructuralPartialEq for Generator
[src]
Auto Trait Implementations
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,