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

Introduce base builder type-alias

Open l4l opened this issue 2 years ago • 2 comments

It's quite handy to have an alias rather than manually recreating the internal type.

fn make_builder() -> FooBuilder<((), (), (), ())> { .. }

// vs

fn make_builder() -> FooBuilder { .. }

l4l avatar Jul 24 '21 09:07 l4l

  1. Why would you ever need to specifically address the base builder type? I can imagine wanting to write a function that returns the builder with some fields filled in, or accept a builder with some fields filled in, or a struct that stores the builder with some fields filled in - but these all are not the base builder. The base builder itself is a fancy unit type.
  2. If you still want to do it - wouldn't it be simpler to use Default Generic Type Parameters?.

idanarye avatar Jul 24 '21 15:07 idanarye

  1. I'd like to expose the type in my API, in particular builder for http client. Apparently the other, more generic option would be adding a trait, but that perhaps quite a big change.
  2. That sounds better, try to look at this.

l4l avatar Jul 25 '21 07:07 l4l