如何让包裹使用与B相同的依赖项?
我有一个像以下项目A和B的项目A和B,B取决于A。A是git子。
repo
|- contrib
|--- A
|----- components
|------- package A
|------- package B
|----- Cargo.toml
|- B
|--- Cargo.toml
A具有以下依赖性,
// A/Cargo.toml
serde = "1.0"
serde_derive = "1.0"
serde_ignored = "0.1"
serde_json = "1.0"
tempfile = "3.0"
lazy_static = "1.3"
我希望B具有相同的依赖项版本,例如A,
// B/Cargo.toml
compA = { path = "../A/components/compA" }
compB = { path = "../A/components/compB" }
serde = "1.0"
serde_derive = "1.0"
serde_ignored = "0.1"
serde_json = "1.0"
tempfile = "3.0"
lazy_static = "1.3"
但是如下,一旦A更新A,它可能会更新其依赖关系。因此,可以稍后使用serde =“ 2.0”
。那么B“自动”如何将其SERDE更新为2.0?
我认为我需要一些说“ B取决于A取决于A的Serde”。
I have a project A and B like the following, B depend on A. A is a git submoudle.
repo
|- contrib
|--- A
|----- components
|------- package A
|------- package B
|----- Cargo.toml
|- B
|--- Cargo.toml
A have dependency like the following
// A/Cargo.toml
serde = "1.0"
serde_derive = "1.0"
serde_ignored = "0.1"
serde_json = "1.0"
tempfile = "3.0"
lazy_static = "1.3"
I want B have the same dependency version like A, like the following
// B/Cargo.toml
compA = { path = "../A/components/compA" }
compB = { path = "../A/components/compB" }
serde = "1.0"
serde_derive = "1.0"
serde_ignored = "0.1"
serde_json = "1.0"
tempfile = "3.0"
lazy_static = "1.3"
However, once A is updated, it may updates its dependencies. So A may use serde = "2.0"
later. So how can B "automaticly" update its serde to 2.0?
I think I need something that says "B depends the serde which A is depending".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它们是同一货物工作区的一部分,那么(由于1.64),您应该使用工作区依赖关系。
否则,
a
应公开/重新删除相关的板条箱(或其部分):然后
b
应使用这些导出,而不是在其<<<<代码> CARGO.TOML :If they are part of the same Cargo workspace, then (since 1.64) you should use workspace dependencies.
Otherwise,
A
should expose/re-export the relevant crates (or parts thereof), for example:and then
B
should use those exports rather than declaring each dependency in itsCargo.toml
: