AndrejOrsula / builder_derive_more

Additional Rust procedural macros for the builder pattern

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

builder_derive_more

crates.io docs.rs Rust deps.rs codecov.io

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.

About

Additional Rust procedural macros for the builder pattern

License:Apache License 2.0


Languages

Language:Rust 81.0%Language:Shell 19.0%