【发布时间】:2019-11-07 13:21:28
【问题描述】:
正如Is it documented that Cargo can download and bundle multiple versions of the same crate? 中所讨论的,Cargo 可以为单个程序引入同一个 crate 的多个版本。如何同时访问这两个版本?
【问题讨论】:
标签: rust rust-cargo
正如Is it documented that Cargo can download and bundle multiple versions of the same crate? 中所讨论的,Cargo 可以为单个程序引入同一个 crate 的多个版本。如何同时访问这两个版本?
【问题讨论】:
标签: rust rust-cargo
截至Rust 1.31,您可以使用rename-dependency Cargo 功能:
[dependencies]
futures-01 = { package = "futures", version = "0.1.0" }
futures-03 = { package = "futures", version = "0.3.0" }
您可以为密钥选择任何您想要的名称。 package 属性必须是 crate 的正式名称。
在您的代码中,您可以使用 crate 名称 futures_01 访问版本 0.1.x,并通过 futures_03 访问版本 0.3.x。
另见:
【讨论】: