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.
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.
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.
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.
To know more about the updates in Rust 1.34, check out its official announcement.
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!