例如:
use futures::future::Future;
fn main() {
let (stop_tokio, time_to_stop) = tokio::sync::oneshot::channel::<()>();
let handler = std::thread::spawn(|| {
tokio::run(
time_to_stop, // .map_err(|_| ())
);
});
handler.join().expect("join failed");
}
编译器输出错误:
error[E0271]: type mismatch resolving `<tokio_sync::oneshot::Receiver<()> as futures::future::Future>::Error == ()`
--> src/main.rs:6:9
|
6 | tokio::run(
| ^^^^^^^^^^ expected struct `tokio_sync::oneshot::error::RecvError`, found ()
|
= note: expected type `tokio_sync::oneshot::error::RecvError`
found type `()`
= note: required by `tokio::runtime::threadpool::run`
该代码需要()
有RecvError
代替,但是编译器打印相反。
这是编译器的一个bug,或者已经我错过了什么?