-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
This new attribute can be placed on individual members or at the top level via #[builder(on(_, overwritable)]. It disables the compile-time check for overwriting already set members. For example with this attribute this code compiles:
#[derive(bon::Builder)]
struct Example {
#[builder(overwritable)]
x: u32,
}
Example::builder()
.x(1)
.x(2)
.build();Why is this useful? It removes a whole bunch of generic state variables and where bounds from the generated code and considerably improves the compile times. For example in the frankenstein repo the difference for me is around 2-3 seconds of compile time.
@EdJoPaTo would you be interested in enabling this in frankenstein to improve the compile times (even at the cost of allowing overwrites)? To me it looks like the problem of overwrites is not that big and the compilation time perf. gains are probably more important.
I have this feature already implemented on my branch #145, and I'm planning to include it in the next release.
A note for the community from the maintainers
Please vote on this issue by adding a 👍 reaction to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.