Release of Rust 1.38 Stable Version

Rust 1.38 has been released, and the contents of the stable version 1.38.0 are as follows:

Pipelined Compilation

If you want to compile a crate, the compiler does not need to fully build dependencies; it only requires their “metadata” (i.e., types, dependencies, exported lists), which is generated early in the compilation process. Starting from Rust 1.38.0, Cargo will leverage this advantage and automatically begin building dependent crates as soon as the metadata is ready.

Although this change does not affect the compilation of individual crates, tests have reported that for builds involving multiple crates, it can bring about a 10-20% increase in compilation speed for clean and optimized builds. Other improvements are minimal, and the speed increase depends on the hardware running the build.

mem::{uninitialized, zeroed}

Starting from 1.38, rustc will provide lints for narrow types that are incorrectly initialized using mem::uninitialized or mem::zeroed.

#[deprecated] Macros

The #[deprecated] attribute was originally introduced in Rust 1.9.0. Rust 1.38.0 extends this attribute to allow it to be applied to macros, marking macros as deprecated using the deprecated attribute.

std::any::type_name

For debugging, obtaining the name of a type can sometimes be useful. For example, in generic code, you might want to see the specific type that a function’s type parameter is instantiated to at runtime. This version allows you to achieve this using std::any::type_name:

fn gen_value<T: Default>() -> T {
    println!("Initializing an instance of {}", std::any::type_name::<T>());
    Default::default()
}

fn main() {
    let _: i32 = gen_value();
    let _: String = gen_value();
}

Output:

Initializing an instance of i32
Initializing an instance of alloc::string::String

Release of Rust 1.38 Stable VersionRelease of Rust 1.38 Stable VersionLibrary Changes

  • slice::{concat, connect, join} now supports &[T] and &T

  • *const T and *mut T now implement maker::Unpin

  • Arc<[T]> and Rc<[T]> implement FormIterator<T>

  • iter::StepBy, Peekable, Take implement DoubleEndedIterator

Additionally, the following features have been stabilized:

  • <span>Duration::div_duration_f32</span> and <span>Duration::div_duration_f64</span>

  • <span><*const T>::cast</span> and <span><*mut T>::cast</span>

  • <span>Duration::as_secs_f32</span> and <span>Duration::as_secs_f64</span>

  • <span>Duration::div_f32</span> and <span>Duration::div_f64</span>

  • <span>Duration::from_secs_f32</span> and <span>Duration::from_secs_f64</span>

  • <span>Duration::mul_f32</span> and <span>Duration::mul_f64</span>

To obtain version 1.38, use the following command:

rustup update stable

Release of Rust 1.38 Stable VersionRelease of Rust 1.38 Stable VersionFor more details, please check the original article.

Open Source China is Calling for Contributions!

Open Source China www.oschina.net is currently a highly regarded and influential open-source technology community, with over 4 million open-source technology elites. We promote the concept of open source, advocate open-source projects, and provide a platform for IT developers to discover, use, and communicate about open-source technologies.

We are now calling for contributions! If you have excellent technical articles to share, or hot industry news to report, please contact Open Source China for submissions. For submission details and contact information, please refer to: I want to submit

Release of Rust 1.38 Stable VersionRecommended Reading

Some iOS devices have permanent unfixable vulnerabilities

Microsoft wants to bring the new Edge browser to Linux

How to deal with open-source companies being “parasitized” by cloud vendors?

Java 13 has been released; do you know the correct usage of thread pools?

Does Microsoft really love open source? The battle between MongoDB and cloud vendors is intensifying

Release of Rust 1.38 Stable Version

Leave a Comment