Get the latest tech news
The weird of function-local types in Rust
Generate builders for everything!
The real code generated by#[bon::builder] is a bit more complex, it uses typestate pattern to catch all potential developer errors at compile time 🐱. Now imagine our builder macro is invoked for a struct defined inside of a local function scope: The compromise is not to use a child module, and obfuscate the private fields of the builder struct with leading__ and#[doc(hidden)] attributes to make it hard for the user to access them (even though not physically impossible).
Or read this on Hacker News