Rust 1.41.0 updates feature relaxed restrictions for trait implementations
Let’s say hello to the newest version of Rust, take a peek at some of the new features introduced in version 1.41.0 stable, as well as a look forward to some of the events happening in 2020. This new update includes some improvements to Cargo, introduces relaxed restrictions for trait implementations, a new Cargo.lock format, some library changes, and a few more tweaks under the hood.
Welcome the latest version of Rust: Version 1.41.10 stable. This update contains a few small new additions, improvements and changes.
As usual, you can easily update to the latest version via rustup with:
$ rustup update stable
We’re happy to announce the release of Rust 1.41.0, featuring relaxed restrictions for trait implementations, Cargo improvements, and many more changes! Check out the highlights in our blog post: https://t.co/jVINf2ESyL
— Rust Language (@rustlang) January 30, 2020
Let’s dive right into the new highlights and see what’s in store.
Implementing traits change
Arguably, the biggest changes introduced in 1.41.0 are the newly relaxed restrictions when implementing traits. According to the announcement blog:
In Rust 1.40.0 this
implwas forbidden by the orphan rule, as both
Vecare defined in the standard library, which is foreign to the current crate. There were ways to work around the limitation, such as the newtype pattern, but they were often cumbersome or even impossible in some cases.
While it’s still true that both
Vecwere foreign, the trait (in this case
From) was parameterized by a local type. Therefore, Rust 1.41.0 allows this
See the original stabilization proposal for additional information.
Rust’s package manager receives a few changes.
- Cargo uses a file called
Cargo.lock, which helps ensure consistent builds and checks dependency versions. This update adds an optimized git-friendly format which will help reduce potential merge conflicts. From now on, this file format will be used for all new lockfiles.
cargo installdetects that a package is out of date, it will now update and reinstall it. This is an improvement upon the old way, which required passing the
--forceflag and reinstalling all binary crates.
- Users can override specific dependency’s build settings.
A note on future compatibility
Rust 1.41.0 will be the last tier 1 release for 32-bit Apple targets. From now on, new releases will be demoted down to tier 3. Tier 3 targets will not be available to download through rustup, but the source code will still be available to build.
Devs that build 32-bit Apple binaries should read the announcement about this reduced support and see how it will affect them.
Misc. Rust 1.41.0 changes
Some other additions included in this update:
- Library changes include the following stabilized APIs: Result::map_or, Result::map_or_else, std::rc::Weak::weak_count, std::sync::Weak::weak_count, and std::sync::Weak::strong_count
- Support for the i686-unknown-dragonfly target has been removed.
- Users can now pass argument files passing the
@pathsyntax to rustc.
The full release notes are available on GitHub.
Meet up plans for 2020?
In addition to this new version, Rust also posted an event line up for 2020 detailing international Rust-related conferences and meetings. Events span across the globe, from Brussels to Berlin, and up from Quebec down to Mexico City.
See if any Rustaceans are meeting in your neck of the woods for hackfests or open source dev meetings.