Registry / utility / derive-builder

derive-builder

JSON →
library0.20.2rscratesunverified

Rust macro to automatically implement the builder pattern for arbitrary structs.

# Cargo.toml [dependencies] derive_builder = "0.20.2"
INSTALL
IMPORT
SIG · DERIVE-BUILDER
D
derive-builder
utilityrustv0.20.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Builder
use derive_builder::Builder;

Derive a builder for a struct and use it to construct instances with optional fields.

use derive_builder::Builder; #[derive(Builder)] struct Person { name: String, age: u32, } let person = PersonBuilder::default() .name("Alice".to_string()) .age(30) .build() .unwrap(); println!("{:?}", person);
Debug
Known issues
gotchaBuilder methods panic on invalid input if not using fallible build
fix
Use .build() which returns Result; handle errors gracefully
affects: >=0.20.0
Upgrade
Version history
0.20.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
derive-builder — cargo add derive-builder · libregistry