Rust 134 releases with alternative cargo registries stabilized TryFrom and TryInto and

first_imgYesterday, 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!last_img

Leave a Reply

Your email address will not be published. Required fields are marked *