September 28, 2023


Networking, Computer, PBX, IT, DIY Solution

The Rust team recently released a new version of Rust 1.70.0.

3 min read

The Rust team recently released a new version of Rust 1.70.0.


The Rust team recently released a new version of Rust 1.70.0. The noteworthy changes in the new version include: enables sparse indexing by default

Cargo’s “sparse” protocol is now enabled by default for reading indexes from This feature was previously stabilized in Rust 1.68.0, but still requires configuration to be available in

The original plan was to enable this feature by default in 1.70.0, but it didn’t happen until now.


You should see a huge performance boost when fetching information from’s index.

If for some reason you need to keep the previous default, which is to use the GitHub-hosted git index, you can use registries.crates-io.protocola configuration setting to change the default.


It should be noted that a side effect of changing the access method is that this also changes the path of the crate cache, so dependencies will be re-downloaded.


OnceCell and OnceLock

OnceCelland its thread-safe counterpart OnceLockTwo new types have been stabilized for one-time initialization of shared data. These two types can be used anywhere that immediate construction is not desired.


use std::sync::OnceLock;

static WINNER: OnceLock<&str> = OnceLock::new();

fn main() {
    let winner = std::thread::scope(|s| {
        s.spawn(|| WINNER.set("thread"));

        std::thread::yield_now(); // give them a chance...

        WINNER.get_or_init(|| "main")

    println!("{winner} wins!");

Crates such as lazy_staticand once_cellhave filled this need in the past, but these building blocks are now part of the standard library, ported over once_cellby unsyncand syncmodules of . There are many more methods that may be stabilized in the future, along with supporting LazyCelland LazyLocktypes that store their initializers.


This new stable feature is_terminalis used to determine whether a given file descriptor (descriptor) or handle (handle) represents a terminal or TTY. A common use case is to let the program distinguish between running in script mode and interactive mode, such as rendering colors or full TUI in interactive mode.

use std::io::{stdout, IsTerminal};

fn main() {
    let use_color = stdout().is_terminal();
    // if so, add color codes to program output...

Named levels of debug information

-CdebuginfoCompiler options previously only supported numbers 0…=2 to increase the amount of debug information, Cargo defaulted to 2 in development and test profiles, and 0 in release and bench profiles. These debug levels can now be set by name: “none” (0), “limited” (1) and “full” (2), and two new levels: “line-directives-only” and “line-tables -only”.

Note that these named options are not yet Cargo.tomlavailable , support for this will be in the next 1.71 release.

test CLI options

The executable gets a command-line interface from the crate when #[test]the function is compiled. testThis CLI has many options, including some that are not yet stable, that need to be specified -Zunstable-options, just like many other commands in the Rust toolchain. However, while this is only allowed in nightly builds, this restriction does not apply testin . However, starting with 1.70.0, the stable and beta versions of Rust will no longer allow the unstable testoption .

There are known cases where unstable options may be used without the user’s knowledge, especially in IntelliJ Rust and other IDE plugins --format json.

More details can be found at:


The Rust team recently released a new version of Rust 1.70.0



Copyright © All rights reserved. | Newsphere by AF themes.