Crates.io | builder_derive_more |
lib.rs | builder_derive_more |
version | 0.1.0 |
source | src |
created_at | 2024-01-06 00:09:35.876594 |
updated_at | 2024-01-06 00:09:35.876594 |
description | Additional procedural macros for the builder pattern. |
homepage | |
repository | https://github.com/AndrejOrsula/builder_derive_more |
max_upload_size | |
id | 1090612 |
size | 28,277 |
Additional Rust procedural macros for the builder pattern.
Add builder_derive_more
as a Rust dependency to your Cargo.toml
manifest.
[dependencies]
builder_derive_more = "0.1"
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();
This project is dual-licensed to be compatible with the Rust project, under either the MIT or Apache 2.0 licenses.
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.