Hacker News new | past | comments | ask | show | jobs | submit login
Bon builder generator 2.0 release (elastio.github.io)
3 points by VeetahaOfficial 9 months ago | hide | past | favorite | 2 comments



Blog post: https://elastio.github.io/bon/blog/bon-builder-generator-v2-...

GitHub repo of the crate: https://github.com/elastio/bon

---

If you are new to `bon`, here is a quick example of it's API. `bon` can generate a builder from a function, effectively solving the problem of named function arguments in Rust described in [the introduction blog post](https://elastio.github.io/bon/blog/how-to-do-named-function-...).

```rust

use bon::builder;

#[builder]

fn greet(name: &str, age: u32) -> String {

    format!("Hello {name} with age {age}!")
}

let greeting = greet()

    .name("Bon")

    .age(24)

    .call();

assert_eq!(greeting, "Hello Bon with age 24!");

```

It also supports generating builders from structs and associated methods. See the [Github repo](https://github.com/elastio/bon) and the [crate overview guide](https://elastio.github.io/bon/guide/overview) for details.

If you like the idea of this crate and want to say "thank you" or "keep doing this" consider giving us a [star on Github](https://github.com/elastio/bon). Any support and contribution are appreciated !

---

From now on I will also be posting updates about `bon` on X (Twitter): https://x.com/veetaha

This post is also available on Reddit: https://www.reddit.com/r/rust/comments/1f1uzkw/bon_builder_g...


It's great to see the rapid iteration on this. Congratulations on the adoption so far!

It must be so cool to work at a company that is cool with open-sourcing projects like this ;)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: