Pattern!() { /* proc-macro */ }
Expand description

Make a Generator for formatted Strings.

The arguments to this macro broadly match the format! macro. The first argument is a format string, and then subsequent arguments must resolve to instances of Generator, whose output will be formatted and inserted into the string as usual.

This macro is particularly useful when deriving Generatable, since it’s quite awkward to construct the necessary lambdas inside the arguments to the boulder attribute.

Example:

use boulder::{Const, Generator, Inc, Pattern};

let mut g = Pattern!("hello-{}-{}", Inc(11i32), Const(4i32));
assert_eq!(g.generate(), "hello-11-4");
assert_eq!(g.generate(), "hello-12-4");
assert_eq!(g.generate(), "hello-13-4");