-
|
I wanted to write a helper function that returns a builder with only some members set. Because of the typestate pattern, a partially set builder has a very complex type that contains private types from the modules that the macro generates, so I can't use them even if I copy the complex type from the compile error message. Is there a way to return a builder from a function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi, it's definitely possible to annotate the type of the builder. It's described on this page. I guess you already noticed that it generates a private module by default. This is done so that the builder's typestate isn't exposed by default, and making it public requires a conscious decision. So, if you want to make the type signature of the builder public, you can change its visibility via |
Beta Was this translation helpful? Give feedback.
Hi, it's definitely possible to annotate the type of the builder. It's described on this page. I guess you already noticed that it generates a private module by default. This is done so that the builder's typestate isn't exposed by default, and making it public requires a conscious decision. So, if you want to make the type signature of the builder public, you can change its visibility via
builder(state_mod(vis = "...")). See more details about that in this section on that page