News: 1620894373

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Rust 2021 edition to arrive in October with 'more consistent panic' and other new features

(2021/05/13)


The Rust 2021 Edition Working Group has scheduled the new version for release in October, with what it says are small changes that amount to a significant improvement.

This is the "third edition of the Rust language," [1]said Mara Bos, founder and CTO of Fusion Engineering and a Rust Library Team member. The previous editions are Rust 2015 and Rust 2018.

"Edition" is a special concept in Rust, as explained [2]here . Updates to Rust ship frequently, but the special feature of an edition is that it can include incompatible changes. A crate (Rust term for a library) has to be explicitly configured to support an edition so older code will continue to work correctly. The Rust compiler can link crates of any edition.

[3]

[4]

[5]

The 2021 edition is not intended to be a big update, as explained in the [6]most recent RFC (Request for Comments). "The Rust 2018 Edition was described in RFC 2052 as being a 'rallying point'... in contrast, the 2021 Edition is intentionally a 'low key' event, which is focused exclusively on introducing some migrations, idiom lints, and other bits of work that have been underway for some time," it says.

Bos said the latest post is the "final list of edition changes." One of the conditions for inclusion was that they were far enough along that the team is confident of their completion in time.

The first new feature that Rust 2021 will have is a new prelude that includes TryInto, TryFrom and FromIterator from the Rust standard library. The feature resolver 2 introduced in Rust 1.51 (March 2021), which is smarter about resolving dependencies, is the default in Rust 2021. Array iteration works as you would expect (until Rust 1.53 code can only iterate over references to arrays, not over arrays directly), despite what Bos called "a small hack to avoid breakage" in older editions. [7]Closures will "only capture the fields that they use", a change which has waited for the new edition for compatibility reasons.

[8]

Rust 2021 also has some changes to the panic!() macro, used to signal an unrecoverable error. This macro accepts an argument that normally describes the error, such as panic!("Divide by zero error");. The macro used to accept any type when invoked with an argument, which could cause problems for outputting the error. In Rust 2021 it will only accept a string, and coders who wish to panic in the old way will need to use panic_any().

Rust adoption is increasing. Microsoft recently released [9]Rust 0.9 for Windows with "access to the entire Windows API surface." Facebook has [10]joined the Rust Foundation and promised to make it "a mainstream language of choice for systems programming and beyond."

Rust in Android: an update

Google is integrating Rust into the Android Open Source Project and has recently given an [11]update on progress .

There are some complications with Rust in Android, particularly around the build system. Normally Rust uses Cargo, its own build system and package manager, but for building Android Google will use [12]Soong , which will call the rustc compiler directly.

It is a trade-off. The Android team said that "Cargo was not designed for integration into existing build systems" but that avoiding it "introduces several challenges and influences many other build system decisions because Cargo usage is so deeply ingrained in the Rust crate ecosystem." The team said: "In the near future, we plan to add documentation to source.android.com on how to define and use Rust modules in Soong." ®

Get our [13]Tech Resources



[1] https://blog.rust-lang.org/2021/05/11/edition-2021.html

[2] https://doc.rust-lang.org/edition-guide/editions/index.html

[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YJz4v0aFsC-BZIfg1dccGAAAAE8&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YJz4v0aFsC-BZIfg1dccGAAAAE8&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33YJz4v0aFsC-BZIfg1dccGAAAAE8&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[6] https://github.com/rust-lang/rfcs/pull/3085

[7] https://doc.rust-lang.org/book/ch13-01-closures.html

[8] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YJz4v0aFsC-BZIfg1dccGAAAAE8&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[9] https://www.theregister.com/2021/05/10/rust_for_windows/

[10] https://www.theregister.com/2021/04/30/facebook_rust/

[11] https://security.googleblog.com/2021/05/integrating-rust-into-android-open.html

[12] https://android.googlesource.com/platform/build/soong/+/refs/heads/master/README.md

[13] https://whitepapers.theregister.com/

claimed

"Real programmers use a cave wall and spit around their hands" comments in 3... 2... 1...

I don't know why they called that function panic()...

LDS

.... to be coherent with the silly naming of new languages just to look "different" they should have called it crater()....

Before anyone asks

DrXym

Yes Rust is backwards compatible. You specify the profile of Rust in your cargo.toml and it acts accordingly.

Aladdin Sane

But isn't Soong often wrong?

Our problem is spaghetti code

_LC_

Our problem is spaghetti code. The programs are falling apart left and right without anybody being able to spot shit.

Our solution: Spaghetti code with better memory management. *lol*

today, n.:
A nice place to visit, but you can't stay here for long.