Rust automatically upgrade to a new edition
Every two or three years, the Rust team produces a new Rust edition. Each edition contains a lot of changes. Each edition brings together the features that have landed into a clear package with fully updated documentation and tooling.
The edition key in Cargo.toml indicates which edition the compiler should use for your code. If the key doesn’t exist, Rust uses 2015 as the edition value for backward compatibility reasons.
Most features will be available on all editions. Developers using any Rust edition will continue to see improvements as new stable releases are made. However, in some cases, mainly when new keywords are added, some new features might only be available in later editions. You will need to switch editions if you want to take advantage of such features.
You can use the cargo fix command to transition your code between different Rust editions. It will update your source code so that it is compatible with the next edition. You might need to set the edition field to the next edition in your Cargo.toml first.
$ cargo fix
For example from
The edition book, transitioning from the 2015 edition to the 2018 edition. This code bellow uses an anonymous parameter, that i32, This is not supported in Rust 2018, so this would fail to compile.
trait Foo {
fn foo(&self, i32);
}
After run the cargo fix:
trait Foo {
fn foo(&self, _: i32);
}
Related Posts
Apache OpenDAL in Rust to Access Any Kind of Data Services
OpenDAL is a data access layer that allows users to easily and efficiently retrieve data from various storage services in a unified way such as S3, FTP, FS, Google Drive, HDFS, etc. They has been rewritten in Rust for the Core and have a binding from many various language like Python, Node.js, C, etc..
Fossil Data Platform Rewritten in Rust 🦀
My data engineering team at Fossil recently released some of Rust-based components of our Data Platform after faced performance and maintenance challenges of the old Python codebase. I would like to share the insights and lessons learned during the process of migrating Fossil's Data Platform from Python to Rust.
Rust Data Engineering: Processing Dataframes with Polars
If you're interested in data engineering with Rust, you might want to check out Polars, a Rust DataFrame library with Pandas-like API.
Cargo: Patch Dependencies
There are several scenarios when you will need to override or patch upstream dependencies. Like testing a bugfix of your crates before pushing to crates.io, a non-working upstream crate has a new feature or a bug fix on the master branch of its git repository that you'd want to try, etc. In these cases, the [patch] section of Cargo.toml might be useful.