3 min read

Yesterday, the rust team released a new version of the Rust systems programming language known for its safety, speed, and concurrency. Rust 1.30 comes with procedural macros, module system improvements, and more.

It has been an incredibly successful year for the Rust programming language in terms of its popularity. It jumped from being the 46th most popular language on GitHub last year to the 18th position this year. The 2018 survey of the RedMonk Programming Language Rankings marked the entry of Rust in their Top 25 list. It topped the list of the most loved programming language among the developers who took the Stack overflow survey of 2018 survey for a straight third year in the row. Still not satisfied? Here are 9 reasons why Rust programmers love Rust.

Key improvements in Rust 1.30

Procedural macros are now available

Procedural macros allow for more powerful code generation. Rust 1.30 introduces two different kinds of advanced macros, “attribute-like procedural macros” and “function-like procedural macros.”

Attribute-like macros are similar to custom derive macros, but instead of generating code for only the #[derive] attribute, they allow you to create new, custom attributes of your own. They’re also more flexible: derive only works for structs and enums, but attributes can go on other places, like functions. Function-like macros define macros that look like function calls.

Developers can now also bring macros into scope with the use keyword.

Updates to the Module system

The module system has received significant improvements to make it more straightforward and easy to use.

In addition to bringing macros into scope, the use keyword has two other changes.

First, external crates are now in the prelude. Previously, on moving a function to a submodule, developers would have some of their code break. Now, on moving a function, it will check the first part of the path and see if it’s an extern crate, and if it is, it will use it regardless of where developers are in the module hierarchy.

Second, use supports bringing items into scope with paths starting with crate. Previously, paths specified after use would always start at the crate root, but paths referring to items directly would start at the local path, meaning the behavior of paths was inconsistent. Now, the crate keyword at the start of the path will indicate if developers would like the path to start at their crate root.

These changes combined will lead to a more straightforward understanding of how paths resolve.

Other changes

  • Developers can now use keywords as identifiers using the raw identifiers syntax (r#), e.g. let r#for = true;
  • Using anonymous parameters in traits is now deprecated with a warning and will be a hard error in the 2018 edition.
  • Developers can now catch visibility keywords (e.g. pub, pub(crate)) in macros using the vis specifier.
  • Non-macro attributes now allow all forms of literals, not just strings. Previously, you would write #[attr(“true”)], now you can write #[attr(true)].
  • Developers can now specify a function to handle a panic in the Rust runtime with the #[panic_handler] attribute.

These are just a select few updates. For more information, and code examples, go through the Rust Blog.

Read Next

3 ways to break your Rust code into modules

Rust as a Game Programming Language: Is it any good?

Rust 2018 RC1 now released with Raw identifiers, better path clarity, and other changes

Content Marketing Editor at Packt Hub. I blog about new and upcoming tech trends ranging from Data science, Web development, Programming, Cloud & Networking, IoT, Security and Game development.