在Rust/Cargo中是否有类似于`go mod tidy`的自动管理依赖的命令?

huangapple go评论86阅读模式
英文:

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.toml
  • cargo remove: removes a dependency from Cargo.toml
  • cargo 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.

huangapple
  • 本文由 发表于 2023年6月13日 12:04:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76461626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定