如 Is it documented that Cargo can download and bundle multiple versions of the same crate? 中所述,Cargo 有可能为单个程序引入同一个 crate 的多个版本。如何同时访问这两个版本?
最佳答案
截至Rust 1.31 , 你可以 rename dependencies在 Cargo.toml 中:
[dependencies]
futures_01 = { package = "futures", version = "0.1.0" }
futures_03 = { package = "futures", version = "0.3.0" }
您可以为 key 选择任何名称。 package
属性需要是包的正式名称。
在您的代码中,您可以使用箱名 futures_01
访问版本 0.1.x,并通过 futures_03
访问版本 0.3.x。
另见:
关于rust - 如何导入同一个 crate 的多个版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58739075/