Prompt
Maintain clean and efficient dependency configurations in Cargo.toml files by following these practices:
- Use workspace inheritance when available for common settings and dependencies:
[package] name = "your_package" version = "0.1.0" edition.workspace = true license.workspace = true [dependencies] some_dependency.workspace = true -
Remove unused dependencies to keep builds efficient and prevent unnecessary bloat.
-
Maintain alphabetical ordering of dependencies to improve readability and make changes easier to track.
- Avoid duplicate version specifications when a dependency is already defined in the workspace. Use the workspace version unless you specifically need a different version:
# Prefer this tokio-util.workspace = true # Instead of this tokio-util = { version = "0.7", features = ["compat"] } - When upgrading a dependency version, ensure compatibility with existing code and consider whether the upgrade should happen at the workspace level.
Following these practices helps maintain a clean dependency tree, reduces build times, and makes configuration files easier to understand and maintain.