kenzu
kenzu is a procedural macro crate for generating builder patterns in Rust โ both immutable and mutable, with optional compile-time validation using field-level attributes.
Whether you're building configuration structs, domain models, or input data, kenzu eliminates boilerplate while increasing safety and clarity.
โจ Features
- ๐งฑ
Builder: Generates immutable, fluent.build()-based builders. - ๐
M_Builder: Generates mutable builders using&mut selfmethods. - ๐งฐ Field-level defaults with
#[set(value = "...")]. - ๐ Regex-based validation with
#[build(pattern = ..., err = ...)]. - ๐ข Range validation with
#[range(min = ..., max = ..., err = ...)]. - ๐งผ Skip trait generation with
#[skip_trait], or skip setters with#[set(skip)]. - โ Compile-time validation of regex patterns โ invalid patterns produce macro errors.
โ๏ธ Installation
Add it to your Cargo.toml:
๐ Usage
Builder
use Builder;
let user = new
.id
.name
.password
.email
.age
.build
.unwrap;
Mutable Builder
use M_Builder;
let mut user = new;
user.id
.name
.password
.email
.fix
.def
.age
.build
.unwrap;