Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 1.68 KB

README.md

File metadata and controls

73 lines (48 loc) · 1.68 KB

macon-rs

Macon logo

Another builder macro-based generator with its own idioms.

Origin

"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.

Usage

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.

Version history

See CHANGELOG.md

Development

Toolchain

Toolchain version is left unspecified, only edition is set. Let's your rustup shims manage it!

Show expansion on test

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'.

Open documenation

cargo doc --document-private-items --no-deps --open

Release

cargo run -p macon_tools --bin release <version>

Then follow instructions.