elastio / bon

Next-gen compile-time-checked builder generator, named function's arguments, and more!
https://bon-rs.com
Apache License 2.0
1.15k stars 17 forks source link

Set default of field to make it optional without Option #119

Closed tontinton closed 1 month ago

tontinton commented 1 month ago

This will allow:

#[builder]
struct Test {
  #[builder_default=true]
  a: bool
}

Also for functions.

Exact syntax can be changed, doesn't really matter.

Veetaha commented 1 month ago

Hi, thank you for creating the issue! If you are looking for an attribute that makes the member optional, then there is such an attribute. It's called #[builder(default)].

If you have any ideas how to improve its discoverability, I'd be happy to hear them 🐱

cablehead commented 1 month ago

I found this one easy to discover in the docs, fwiw

Veetaha commented 1 month ago

@tontinton see my comment https://github.com/elastio/bon/issues/119#issuecomment-2337546162, if that answers you question then close the issue.

I'll close the issue myself If I won't receive feedback from @tontinton

tontinton commented 1 month ago

oh ok thanks, I just missed it in the docs