Home United States USA — software Rust 1.19 Adds Untagged Unions and More

Rust 1.19 Adds Untagged Unions and More

340
0
SHARE

Rust 1.19 introduces a number of language improvements, including non-tagged unions, and new standard library features.
Rust 1.19 introduces a number of language improvements, including non-tagged unions, and new standard library features.
Unions in Rust are similar to enums, but they are untagged. This implies that using union s in Rust is intrinsically unsafe, since no information is available to tell which variant of the union is effectively in use. This is how you can declare and use a Rust union:
Besides making it easier for developers to interface with C APIs that expose unions, the introduction of unions in Rust also aims to simplify the implementation of space-efficient structures.
In Rust 1.19, a loop statement can now behave as an expression when used with break to return a value from it. E.g.:
On the library front, as mentioned, Rust 1.19 also includes a number of new features. Firstly, a couple of new macros, eprint! and eprintln!, make it straightforward to write to standard error instead of standard output.
Other new library features are the following:
Rust package manager, Cargo, also includes a few improvements. In particular, it no longer checks out a local working directory for the crates.io index, which contributes to improving performance and reduce the registry size. Additionally, build scripts can modify the environment they use to build a crate; the new –exclude option can be used to exclude specific packages when using –all.
If you already have Rust installed, you can update it by running:
Otherwise, you can use rustup to build it for the first time.
Make sure to read the detailed release notes for more information.

Continue reading...