Why you shouldn't obsess about Rust "features"

Why you shouldn't obsess about Rust "features"

Rust makes it very easy to express conditional compilation, specially thanks to its “features”. They’re well integrated into the language and are very easy to use. But one thing I’ve learned by maintaining RSpotify (a library for the Spotify API) is that one shouldn’t obsess over them. Conditional compilation should be used when it’s the only way to solve the problem, for a number of reasons I’ll explain in this article....

July 6, 2021 · 7 min · Mario Ortiz Manero
Optional parameters in Rust

Optional parameters in Rust

Optional or default parameters are a very interesting feature of some languages that Rust specifically doesn’t cover (and looks like it won’t anytime soon). Say your library has lots of endpoints like so: fn endpoint<T1, T2, T3, ...>(mandatory: T1, opt1: Option<T2>, opt2: Option<T3>, ...); In this case, when you call endpoint, you have to use endpoint(mandatory, None, None, ...), or endpoint(mandatory, Some(val1), Some(val2), ...), instead of the more intuitive endpoint(mandatory) or endpoint(mandatory, val1, val2)....

October 10, 2020 · 11 min · Mario Ortiz Manero