News

Rust 1.34 releases with alternative cargo registries, stabilized TryFrom and TryInto, and more

2 min read

Yesterday, the Rust team announced the release of Rust 1.34. This release introduces alternative cargo registries, includes support for ‘?’ operator in documentation tests, stabilized TryFrom and TryInto, and more.

Support for alternative cargo registries

Rust provides a public crate registry called crates.io where developers can publish crates with the cargo publish command. However, as this crate registry is not for people maintaining proprietary code, they are forced to use git or path dependencies. This release brings support for alternate cargo registries, which coexists with crates.io. So, users will now be able to write software that depends on crates from both crates.io and their custom registry.

Support for the ‘?’ operator in documentation tests

It was proposed in RFC 1937 to add support for the ‘?’ operator in the main() function, #[test] functions, and doctests allowing them to return Option or Result with error values.  This ensured a non-zero exit code in the case of the main() function and a test failure in the case of the tests.

Support for the main() and #[test] functions were already implemented in previous versions. However, in the case of documentation tests, support for ‘?’ was limited to doctests that have an explicit main() function. In this release, the team has implemented full support for ‘?’ operator in doctests.

Stabilized TryFrom and TryInto

The TryFrom and TryInto traits that were proposed in an RFC back in 2016 are finally stabilized in this release to allow fallible type conversions. A ‘Infallible’ type is added for conversions that cannot fail such as u8 to u32. In future versions, the team plans to convert Infallible to an alias for the (!) never type.

Library stabilizations

  • This release comes with an expanded set of stable atomic integer types with signed and unsigned variants from 8 to 64 bits available.
  • In the previous versions, non-zero unsigned integer types, for example, NonZeroU8 were stabilized. With this release, signed versions are also stabilized.
  • The ‘iter::from_fn’ and ‘iter::successors’ functions are also stabilized.

To know more about the updates in Rust 1.34, check out its official announcement.

Read Next

Chris Dickinson on how to implement Git in Rust

The npm engineering team shares why Rust was the best choice for addressing CPU-bound bottlenecks

Rust 1.33.0 released with improvements to Const fn, pinning, and more!

 

Bhagyashree R

Share
Published by
Bhagyashree R

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