Another builder macro-based generator with its own idioms.
"Maçon" (pronounced: \ma.sɔ̃\) is French translation for "builder".
Idea for creating a new builder generator comes from benchmarking solutions at: https://github.com/loganmzz/rust-benchmark-setter.
macon
crate provides a derive macro:
#[macro_use] extern crate macon;
#[derive(Builder)]
struct MyType {
integer: i32,
string: String,
optional: Option<String>,
}
let _mytype: MyType = MyType::builder()
.integer(42)
.string("foobar")
.build();
#[derive(Builder)]
struct MyTuple(
i32,
String,
Option<String>,
);
let _mytuple: MyTuple = MyTuple::builder()
.set(42)
.set("foobar")
.build();
See crate documentation for more information about available options.
See CHANGELOG.md
Toolchain version is left unspecified, only edition is set. Let's your rustup
shims manage it!
The tests/*.rs
are good way to see how to use and debug macro. Consider expanding test files with: cargo expand --test <test basename>
. Example: cargo expand --test 'mode_panic'
.
cargo doc --document-private-items --no-deps --open
cargo run -p macon_tools --bin release <version>
Then follow instructions.