英文:
Is there a command in rust/cargo which manage dependency automatically like `go mod tidy`
问题
Rust/Cargo 中是否有像 "go mod tidy" 一样自动管理依赖的命令,还是我们必须手动编写 "Cargo.toml" 文件的内容?
英文:
Is there a command in rust/cargo which manage dependency automatically like go mod tidy
, Or we must write the content of Cargo.toml
manually
答案1
得分: 3
Cargo内置了一些subcommands来管理依赖项:
cargo add
:向Cargo.toml添加依赖项cargo remove
:从Cargo.toml中删除依赖项cargo update
:更新Cargo.lock中的依赖项(不影响Cargo.toml)
对于第三方工具,我认为没有自动添加依赖项的功能,但有一个用于删除未使用依赖项的工具叫做cargo-machete。
英文:
Cargo has a few subcommands built-in for managing dependencies:
cargo add
: adds a dependency to Cargo.tomlcargo remove
: removes a dependency from Cargo.tomlcargo update
: Updates dependencies in Cargo.lock (doesn't affect Cargo.toml)
For third-party tools, I don't think there's anything for adding dependencies automatically, but there's cargo-machete for removing unused dependencies.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论