News

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

2 min read

Rust 2018 RC1 was released yesterday. This new version of the Rust programming language contains features like raw identifiers, better path clarity and other additions. Some of the changes in Rust 2018 RC1 include:

Raw identifiers

Like many programming languages, Rust too has the concept of “keywords”. These identifiers cannot be used in places like variable names, function names, and other places. With Rust 2018 RC1, raw identifiers let you use keywords where they are not allowed normally. New confirmed keywords in Rust 2018 RC1 are async, await, and try.

Better path clarity

One of the hardest things for people new to Rust is the module system. While there are simple and consistent rules defining the module system, their consequences can appear to be inconsistent and hard to understand.

Rust 2018 RC1 introduces a few new module system features to simplify the module system and give a better picture of what is going on.

  • extern crate is no longer needed. The crate keyword refers to the current crate. Absolute paths begin with a crate name, where again the keyword crate refers to the current crate.
  • A foo.rs and foo/ subdirectory may coexist. mod.rs is no longer required when placing submodules in a subdirectory.

Anonymous trait parameters are deprecated

Parameters in trait method declarations are no longer allowed to be anonymous.

In Rust 2015, the following was allowed:

trait Foo {
    fn foo(&self, u8);
}

In Rust 2018 RC1, all parameters require an argument name (even if it’s just _):

trait Foo {
    fn foo(&self, baz: u8);
}

Non-lexical lifetimes

The borrow checker has been enhanced to accept more code. This is performed via a mechanism called ‘non-lexical lifetimes’. Previously, the below code would have produced an error, but now it will compile just fine:

fn main() {
    let mut x = 5;
    let y = &x;
    let z = &mut x;
}

Lifetimes follow “lexical scope”. This means that the borrow from y is considered to be held until y goes out of scope at the end of main. This is the case even though y will never be used again in the code. The above code works fine, but in the older versions, the borrow checker was not able handle it.

Installation

To try and install Rust 2018 RC1 you need to install the Rust 1.30 beta toolchain. This beta is a little different from the normal beta, states the Rust Blog.

> rustup install beta
> rustc +beta --version 
rustc 1.30.0-beta.2 (7a0062e46 2018-09-19)

The feature flags for Rust 2018 RC1 are turned on and can be used to report issues.

These were only a select few changes. Other changes in this beta include Lifetime elison in impl, T: ‘a inference in structs, macro changes etc. For more information and details on the complete list of updates, read the Rust edition guide where the new features are marked as beta.

Read next

Rust 1.29 is out with improvements to its package manager, Cargo

Deno, an attempt to fix Node.js flaws, is rewritten in Rust

Creating Macros in Rust [Tutorial]

Prasad Ramesh

Data science enthusiast. Cycling, music, food, movies. Likes FPS and strategy games.

Share
Published by
Prasad Ramesh

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago