Better HN
topnewbestaskshowjobs
Log inSign up

VeetahaOfficial

1 karma · joined Aug 26, 2024 (2y ago) · 4 submissions

Submissions

1.

[Rust] Next-gen builder macro Bon 3.0 release. Revolutional typestate design(bon-rs.com ↗)

8 points · by VeetahaOfficial · 2y ago · discuss

comment 2y ago · link · parent

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...

3.

Bon builder generator 2.0 release(elastio.github.io ↗)

3 points · by VeetahaOfficial · 2y ago · 2 comments