#derive-builder #builder-pattern #builder #derive #proc-macro #procedural

macro builder_derive_more

Additional procedural macros for the builder pattern

1 unstable release

0.1.0 Jan 6, 2024

#29 in #derive-builder

Download history 30/week @ 2024-07-20 16/week @ 2024-07-27 34/week @ 2024-08-03 10/week @ 2024-08-10 12/week @ 2024-08-17 13/week @ 2024-08-24 42/week @ 2024-08-31 19/week @ 2024-09-07 44/week @ 2024-09-14 50/week @ 2024-09-21 39/week @ 2024-09-28 11/week @ 2024-10-05 66/week @ 2024-10-12 21/week @ 2024-10-19 37/week @ 2024-10-26 27/week @ 2024-11-02

152 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

10KB

builder_derive_more

crates.io Rust codecov

Additional Rust procedural macros for the builder pattern.

Instructions

Rust

Add builder_derive_more as a Rust dependency to your Cargo.toml manifest.

[dependencies]
builder_derive_more = "0.1"

Usage

Hereafter, you can #[derive(IntoBuilder)] alongside deriving the builder pattern (e.g. via derive_builder).

use builder_derive_more::IntoBuilder;
use derive_builder::Builder;

#[derive(Builder, IntoBuilder)]
pub struct Foo {
    bar: String,
}

This allows you to convert from the struct with named fields back into the builder for configuration.

// `IntoBuilder` derive provides the `Foo::builder()` and `Foo::configure(self)` methods.
let foo: Foo = Foo::builder().bar("bar").build().unwrap();
let foo_builder: FooBuilder = foo.configure();

License

This project is dual-licensed to be compatible with the Rust project, under either the MIT or Apache 2.0 licenses.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~225–670KB
~16K SLoC