You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compile failed when tokio::sync::mpsc::Sender send format!() String.
I am not sure if this is a compiler bug or a problem with tokio.
use tokio::sync::mpsc::{Sender, channel};
use tokio::runtime::{self};
use futures::{FutureExt, TryFutureExt, StreamExt};
use std::thread::sleep;
use std::time::Duration;
fn main() {
let runtime = runtime::Builder::new()
.core_threads(2)
.name_prefix("tokio-")
.build()
.map_err(|e| panic!("New Runtime failed: {:?}", e))
.expect("tokio runtime error");
let (tx, rx) = channel::<String>(2);
let e = runtime.executor();
e.spawn(t(tx.clone()));
e.spawn(async move {
let mut rx = rx;
while let Some(s) = rx.next().await{
println!("{}", s);
}
});
sleep(Duration::from_secs(10));
}
async fn t(tx: Sender<String>) {
let mut t = tx.clone();
for i in 0..5u8 {
let s = format!("{}", i);
t.send(s).map_err(|_| ()).map(|_| ()).await;
// can't compile
// t.send(format!("{}", i)).map_err(|_| ()).map(|_| ()).await;
}
}
The text was updated successfully, but these errors were encountered:
Version
tokio-0.2-alpha.6
rust nightly-20191024
Platform
Manjaro Linux AMD64
Description
Compile failed when tokio::sync::mpsc::Sender send
format!()
String.I am not sure if this is a compiler bug or a problem with tokio.
The text was updated successfully, but these errors were encountered: