Is there a way to remove everything from the target directory apart from the release binary?

Viewed 1112

Can cargo clean remove everything from the target/ directory apart from the release binary? The default linking option in Rust is statically linked binaries, so dependencies are only there to improve recompilation/incremental.

AFAIK, cargo clean provides options to specify which target I want to clean up for. Is there a cargo clean flag that I am missing that does that?

1 Answers

No, there is not.

I'd just move the binary out of the target directory and then run cargo clean.

Related