Closed SephVelut closed 5 years ago
// Cargo.toml // [dependencies] // runtime = { version = "0.3.0-alpha.5", feature = ["native"] } // futures-preview = "0.3.0-alpha.16" #![feature(async_await)] use futures::prelude::*; use runtime::net::TcpListener; use futures::executor::block_on; async fn listener() -> std::io::Result<()> { let mut listener = TcpListener::bind("127.0.0.1:8080")?; let mut sockets = listener.incoming(); while let Some(socket) = sockets.next().await { match socket { Ok(s) => { runtime::spawn(async move { let (reader, writer) = &mut s.split(); reader.copy_into(writer).await?; Ok::<(), std::io::Error>(()) }).await?; }, Err(_) => (), } } Ok::<(), std::io::Error>(()) } fn main() { block_on(listener()); }
thread 'main' panicked at 'the runtime has not been set', src/libcore/option.rs:1034:5
Related to https://github.com/rustasync/runtime/issues/42 . There's currently no API to explicitly run a runtime.
Ah okay thank you
thread 'main' panicked at 'the runtime has not been set', src/libcore/option.rs:1034:5