Workspace Inheritance in Rust

SotoEstevez on 2022-09-22

A look at the new feature of Rust 1.64

Photo by Rod Long on Unsplash

Rust 1.64 has arrived today and this version will impact hundreds of projects of all types around the web.

The reason for this is that it comes with a key feature to any project divided into a plethora of different crates. This feature is the workspace inheritance, which will allow us to share fields like version numbers or metadata fields between crates. The Cargo.toml file has started to follow the DRY principle, at last.

Say goodbye to copy-pasting licenses and authors

One of the first things anyone does when they create a new crate is to open the manifest of a previous one and copy all the sections that are common between both — even if they are in the same workspace.

For example, in the repository that I use to showcase the code examples, you can see that I used to have the same authors key in each crate. Now I can take out all that duplication. How? First, making the root Cargo.toml to be like this: