-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbasic.rs
27 lines (22 loc) · 799 Bytes
/
basic.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use jen::generator::Generator;
use runiq::{Filter, QuickFilter};
fn main() {
// First we create a filter to detect duplicates
let mut filter = QuickFilter::default();
// As well as a template to generate random inputs
let template = "{{ integer(start=1, end=6) }}";
// Then we generate some random input values
let inputs = Generator::from_string(template)
.unwrap()
.take(20)
.collect::<Vec<_>>();
// And filter uniques
let outputs = inputs
.iter()
.filter(|v| filter.detect(v.as_bytes()))
.map(|v| v.to_owned())
.collect::<Vec<_>>();
// Before we print the before/after to the console
println!("Generate values: {}", inputs.join(", "));
println!("Filtered values: {}", outputs.join(", "));
}