The developers behind the programming language Rust have announced the release of Rust 1.70.0.
One of the changes in this release is that the “sparse” protocol for reading the crates.io index is now enabled by default. The team says that using this protocol to get information from the index will allow for significant performance improvements. They also noted that one side effect of this feature is that the path to the crate cache has changed, so dependencies will need to be re-downloaded.
This release also features two new types for initializing shared data: OnceCell and OnceLock. OneLock is a thread-safe version of the type. The new types can be used anywhere immediate construction isn’t a wanted behavior. In the past, developers have used crates like “lazy_static” and “once_cell” to fill this need, but this is no longer necessary. Both of these new types are considered stable features in this release.
Another stable new feature in Rust 1.70.0 is IsTerminal, which uses the method “is_terminal” to decide whether “a given file descriptor or handle represents a terminal or TTY.” Previously there was crate functionality that could achieve the same functionality, but now it is built into the language.
Also in this release is the ability to name debug levels. According to the Rust release team, the “-Cdebuginfo” compiler option is used to only support numbers 0 to 2. Now they can be set by name using “none” for 0, “limited” for 1, and “full” for 2. There are also two new levels being introduced: “line-directives-only” and “line-tables-only.” “Line-directives-only” is intended for NVPTX profiling and “line-tables-only” specifies to use of the minimum needed for backtraces with filenames and line numbers.
And finally, as of this release, the language will no longer allow unstable test options. Previously the command line would allow users to select options that weren’t yet stabilized. This was intended to only be used in nightly builds, but prior to this release, that restriction wasn’t officially in place.
This release also includes a number of newly stabilized APIs. For a full list of those, visit the official release notes.