How to save disk space?

Cargo will download dependencies for each crate, which consumes a lot of disk space.

Sometimes different crates may share the same dependencies so that it is not necessary to download duplicated contents.

Is there a method to share same dependencies between different crates?

Thanks

Cargo does that automatically. It doesn't download the same exact dependency twice.

Thanks, I realized that the downloaded files exist in ~/.cargo/registry/cache/ so no duplicated download is performed.

However, there is still a lot of rlib files in target/(release|debug)/deps. These files make the crate directory occupies a lot of disk space, can this be avoided?

I think there is some work that allows caching of build artifacts across projects. See sccache.