This crate is based around two derive macros, Buildable
and
Generatable
which provide a method to construct a Builder
and
Generator
respectively for your type, wrapping up a lot of
boilerplate within them.
Builder
A Builder
is a way to create a single object, specifying only the
fields you wish to give non-default values. The default values are
specified using attributes on your type for ease of reading. Each
field gains a method of the same type in the builder which can be
be used to customise it.
Example
use ;
let f = builder
.a
.build;
assert_eq!;
assert_eq!;
Generator
A Generator
is a way to create an infinite sequence of objects,
again specifying only the function for generating the fields you
wish to have non-default sequences. The default sequences are
specified using attributes on your type for ease of reading. Each
field gains a method of the same type in the generator which can
be be used to customise the sequence of values it takes between
objects.
Example
use ;
let mut n = 2;
let mut gen = generator;
gen.a;
let bar1 = gen.generate;
assert_eq!;
assert_eq!;
let bar2 = gen.generate;
assert_eq!;
assert_eq!;