Show HN: Zero-overhead compile-time builder pattern for Rust

github.com

8 points

cat-whisperer

2 days ago


1 comment

cat-whisperer 2 days ago

We've all used builder patterns. And though they're elegant, debugging them can be frustrating. I discovered this while working with a large struct – missing a field only surfaced during runtime, which wasn't ideal. That got me thinking: since we're using Rust, why not leverage the compiler to catch these issues for us?

That's why I created buco. It's a simple yet powerful crate that gives you all the benefits of the builder pattern, but moves all the checks to compile time. If you miss a field, the compiler won't even let you call the build method.