4 ms·
Currently this is the only thing slightly bothering me when writing Rust code, everything else is an absolute blast and I'm loving every second of it. Hopefull
by axiosgunnar 5y ago
Currently this is the only thing slightly bothering me when writing Rust code, everything else is an absolute blast and I'm loving every second of it.
Hopefully an industry wide best-practice will develop soon on how to deal with the problems outlined in the article.
Does anybody know what a Phantom Builder is? The article teases it but doesn't say anything.
- b3morales 5y ago> Does anybody know what a Phantom Builder is? Stab in the dark but I would guess that it's using a phantom type parameter to record the state of the builder with regard to its required parameters. This lets you keep the required parameters out of the builder's own constructor, but make the final `build` function only available if the builder is in the right state -- according to the phantom type.
- alpaca128 5y agoIn my personal projects I usually define macros. They can handle a varying number of arguments, which helps a lot. Though sometimes Rust macros feel just a bit too strict for me, the way they are checked outright prevents some uses. At the same time they've been really helpful for letting me define a lot of options with a compact syntax.
- axiosgunnar 5y agoThanks for the tip, I will keep this in mind