从Tokio Core导入频道模块失败

时间:2018-11-16 18:17:39

标签: rust rust-tokio

在lib.rs内部,我有这个:

Concatenate

最终会出现此错误:

extern crate tokio_core;
use tokio_core::channel::{channel, Sender, Receiver};

tokio_core crate's lib.rs file,它以如下方式导出error[E0432]: unresolved import `tokio_core::channel` --> src/main.rs:2:17 | 2 | use tokio_core::channel::{channel, Sender, Receiver}; | ^^^^^^^ Could not find `channel` in `tokio_core`

channel

对于我的一生,我不知道为什么这行不通。我已经在Rust 1.29和1.30.1上都尝试过。

1 个答案:

答案 0 :(得分:2)

如果您查看channel.rs的顶部,则会发现整个模块已被弃用,并且只有在添加适当的功能后才能使用:

#![deprecated(since = "0.1.1", note = "use `futures::sync::mpsc` instead")]
#![allow(deprecated)]
#![cfg(feature = "with-deprecated")]

但是,Cargo.toml甚至不允许启用此功能,并且它apparently never did。实际上,整箱现在已被弃用:

  

弃用通知。

     

此板条箱计划弃用,有利于   tokio

     

tokio-core仍在积极维护中,但仅会修正错误   应用。所有新功能的开发都在进行中   tokio

如弃用通知中所述,请改用futures::sync::mpsc::channel