generator-combinator
Provides parser-combinator-like combinable text generation in Rust.
You can add this crate to your Rust project with generator-combinator = "0.1.0"
. Documentation on docs.rs and crates.io listing.
To generate street address-like input, only a few components are required. We can quickly produce a range of nearly 1B possible values that can be fully iterated over or randomly sampled:
use Generator;
let space = from;
let number = Digit * ;
let directional = space.clone + oneof!;
let street_names = space.clone + oneof!;
let street_suffixes = space.clone + oneof!;
let address = number // street number is 3-5 digits long
+ directional.clone.optional // optional pre-directional
+ street_names
+ street_suffixes
+ directional.clone.optional; // optional post-directional
assert_eq!;
let addr_values = address.values;
println!; //Example: 344 W Yesler Way
println!; //Example: 702 NE Spring Ct N
println!; //Example: 803 SW Madison Way SE
This library is 0.1.0 - there may be issues, functionality may be incomplete, etc.
Known issues / nota bene
- Generated digits include leading zeros
TODO
- Consider including
Fn
variants ofGenerator
-
Generator
post-processing of component strings (eg, to strip leading zeros) before combining output