1

I need to use both futures-preview and futures in my project. My Cargo.toml looks like:

[dependencies]
futures-preview = "= 0.3.0-alpha.7"
futures = "0.1.25"

Now, in my lib.rs, when I do

extern crate futures;

Rust got confused about which futures crate to use. How can I use these two crates that have the same extern crate name at the same time?

   Compiling spdk-rs v0.1.0 (/home/zeyuanhu/share/rustfs/spdk-rs)
error[E0465]: multiple rlib candidates for `futures` found
  --> /home/zeyuanhu/share/rustfs/spdk-rs/src/lib.rs:17:1
   |
17 | extern crate futures;
   | ^^^^^^^^^^^^^^^^^^^^^
   |
note: candidate #1: /home/zeyuanhu/share/rustfs/examples/hello_nvme_bdev_rust_wrapper/target/debug/deps/libfutures-ac8c40146fd4a4e0.rlib
  --> /home/zeyuanhu/share/rustfs/spdk-rs/src/lib.rs:17:1
   |
17 | extern crate futures;
   | ^^^^^^^^^^^^^^^^^^^^^
note: candidate #2: /home/zeyuanhu/share/rustfs/examples/hello_nvme_bdev_rust_wrapper/target/debug/deps/libfutures-44db24e7af1a2bd3.rlib
  --> /home/zeyuanhu/share/rustfs/spdk-rs/src/lib.rs:17:1
   |
17 | extern crate futures;
   | ^^^^^^^^^^^^^^^^^^^^^

error[E0463]: can't find crate for `futures`
  --> /home/zeyuanhu/share/rustfs/spdk-rs/src/lib.rs:17:1
   |
17 | extern crate futures;
   | ^^^^^^^^^^^^^^^^^^^^^ can't find crate
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
xxks-kkk
  • 2,336
  • 3
  • 28
  • 48
  • I believe your question is answered by the answers of [How to alias a crate in Rust 2018 idiomatically?](https://stackoverflow.com/q/50999616/155423). If you disagree, please [edit] your question to explain the differences. Otherwise, we can mark this question as already answered. – Shepmaster Dec 13 '18 at 23:12
  • 1
    TL;DR, use the `package` key in your Cargo.toml for one of the dependencies. – Shepmaster Dec 13 '18 at 23:13
  • 1
    That works! Thanks! – xxks-kkk Dec 13 '18 at 23:25

0 Answers0