Rust builder pattern with types

Intro Rust has a very rich type system. It also has move semantics. Using these two features together you can build your APIs using the builder pattern. Let’s see an actual example on why you would want to use the builder pattern and how to implement is (well, I’m showing you a way to implement it, not necessarily the best one). Example Suppose we have a function that takes a lot of parameters: some of them are mandatory, others are optional....

26 July 2018 · 8 min · Francesco Cogno