rust-typed-builder icon indicating copy to clipboard operation
rust-typed-builder copied to clipboard

Code cleanup. Make build method generate as const

Open DanikVitek opened this issue 8 months ago • 3 comments

  • Add #![forbid(rust_2018_idioms)] to the typed-builder-macro crate
  • Make the builder function const when possible

DanikVitek avatar Oct 15 '23 19:10 DanikVitek

Given how the setter methods are not const, and the build method is not const, is it really useful to make the builder method const?

idanarye avatar Oct 15 '23 23:10 idanarye

Given how the setter methods are not const, and the build method is not const, is it really useful to make the builder method const?

Not really. I'm not sure if it would be possible because of deconstruction of self. Currently it's not possible in const fn afaik

DanikVitek avatar Oct 16 '23 07:10 DanikVitek

Once https://github.com/rust-lang/rust/issues/67792 gets stabilized, builder, build, and all the setters could be const - and that would be controlled via a flag on the attribute (#84). Until then, I see no point in making only the builder method const.

idanarye avatar Oct 16 '23 10:10 idanarye