BT

Facilitating the spread of knowledge and innovation in professional software development

Contribute

Topics

Choose your language

InfoQ Homepage News Rust 2021 Edition is Here: Q&A with Armin Ronacher

Rust 2021 Edition is Here: Q&A with Armin Ronacher

This item in japanese

Bookmarks

Rust 2021 Edition hit the road perfectly on schedule on October 21, along with Rust 1.56.0. The latest version of the language includes support for disjoint capture, or patterns in macro rules, and more.

InfoQ reported about Rust 2021 Edition when it was initially announced last May. We discussed there the importance of editions for the evolution of the language as a mechanism that enables improvements while ensuring backward compatibility.

Two highlights among new features that made into the 2021 editions are disjoint capture in closure and the introduction of or patterns in macro rules.

Disjoint capture provides finer-grade capturing of values or references inside closures. For example, if a closure only uses a field from a structure, then Rust 2021 will capture that specific field and not attempt to capture the entire structure, which was not allowed:

//-- this is now allowed, whereas previously you had to capture
//-- the field separately using let y = &a.y
let c = || print!("{}", aStruct.y);

When using macros, you can now use or patterns, expressed using the | operator. For example, you can write Some(1 | 2) whereas you had to use Some(1) | Some(2) in previous versions. This comes down to the fact the $_:pat specifier used in macro definition was not able to match the |, while it now does.

Another major change to Rust syntax in the 2021 edition concerns the into_iter, which can be used to iterate over an array. array.into_iter() now iterates over items by value, whereas it used to do it by reference. The syntax array.into_iter() will resolve to (&array).into_iter() in older version of the language to ensure backward compatibility.

InfoQ has taken the chance to speak with Sentry director of engineering, Armin Ronacher, about where Rust is standing now.

InfoQ: You have been involved with Rust at least since 2015. Could you briefly describe your work and experience with Rust?

Armin Ronacher: I first learned about Rust in 2012, a few years before it hit the 1.0 release. I found the concept of the language very interesting, and the roadmap, community and principles behind it impressed me. When I started working at Sentry, I slowly introduced Rust into our infrastructure where it made sense, and it has since been a core language at Sentry.

InfoQ: You are known as the author of the popular Python Flask framework. One could say Rust and Python are a pretty uncommon combination to be found in the same person. How do you live with that dualism?

Ronacher: I would argue that Python and Rust go hand-in-hand these days. Over the years, Python developers became used to writing extensions in C, C++ and Cython, and this is how many of them came to know Rust. Rust is an excellent language to write Python extension modules in libraries like PyO3. Also, interacting with the Rust community gave me strong early Python vibes.

InfoQ: What are in your opinion the three most compelling features that Rust 2021 edition will bring to developers?

Ronacher: The 2021 edition is not a huge step and that’s very much intentional. The editions are a way to make code more modern and clean up problems that would otherwise be backwards incompatible. The example here is that you can now get an array iterator, which was impossible previously in a backwards compatible manner. Most of the new features are available even when you’re in an older edition of the compiler. In that sense, I don’t expect major changes. That said, the 2021 edition is reserving a whole bunch of stuff in anticipation of what’s to come. In particular I’m counting down the days when format strings are a feature.

InfoQ: Speaking of Rust present and future, where does the language stand right now?

Ronacher: Rust stands on firm grounds in many spaces already, particularly where performance is needed. The situation is less clear-cut for web services. There is still a lot missing to make Rust an ideal language for services (slow compile times, relatively weak HTTP ecosystems, suboptimal async IO story). At the same time, there is constant work done in those spaces, and it’s just a matter of time before Rust makes some significant improvements there. What’s fascinating about Rust is that it seems like it’s constantly being picked up in environments where it’s immature, and matures with relatively large users. I have seen it show up on mobile devices, IoT devices, set-top boxes, WASM, computer games, serverless, and more. Very few languages, other than C++, have started capturing such a wide variety of environments.

Rust 2021 edition includes many more features than can be covered here, so do not miss the official announcement for the full details.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT