Rust stability in 2019

Everyone here is very aware of what C++ has become, so this fate is considered and actively avoided.

The current state of fragmentation is:

  • try!() macro has been adopted as ? syntax. Some projects still use try!(), but both syntaxes work. There's no need to change, but if you want, it can be converted automatically.

  • Box<Trait> has got clearer syntax as Box<dyn Trait>. Some code still uses the less obvious syntax. Both work. There's no need to change, but you can with cargo fix --edition-idioms.

  • The experimental futures crate 0.1 will become obsolete when Future type is added to stdlib. There's a plan to make adapter for backwards compatibility. There will be some annoying churn as projects switch, but the big upside is that it will work with the async/await syntax that is soooo much easier to work with than the raw futures crate.

  • trim_left_matches was renamed to trim_start_matches. The old method still works, but shows a warning. You can silence the warning or use cargo fix to rename.

  • modules changed, with addition of crate:: to paths. Modules were super confusing to new users and paths seemed to be inconsistent. Old code still works, but can be auto-converted with cargo fix --edition.

There were other changes, like making ref de-facto optional and dropping of useless Error::description(), but these changes essentially removed things from the language.

The additions on the horizon are:

  • async/await that are relatively big, but also very desirable for networking code. Currently when you use async code you have to fight with the borrow checker a lot, since use of references and local variables is limited. This change will allow networking code to look more like in Go or JS.

  • const generics. Currently any generic types depending on numbers (like array length or dimensions of a matrix) are either impossible, overcomplicated or buggy. So that's more a language-level bug fix than a new feature.

And that's all I can think of for 2015-2019. We'll see how the switch to new futures will work out, but for other features it comes down to running a tool once a year, and even that is optional. You can do nothing if you don't care about newer features.

12 Likes