bon
A Rust crate that generates compile-time-checked builders for structs and functions, plus named and optional function parameters, using the typestate pattern to prevent missing or repeated arguments.
bon is a Rust crate for generating builders for structs and functions, and for turning functions with positional parameters into ones with named, optional parameters. A #[builder] attribute on a function creates a builder-style call with named setters, and #[derive(Builder)] does the same for a struct's fields; both share the same attributes API.
Generated builders use the typestate pattern so that a missing required parameter, or calling the same setter twice, is caught as a compile error rather than a runtime bug. Instance and associated methods are both supported.
It is added as a Cargo dependency and can be used without the standard library or allocator by disabling default features, for no_std environments.