From 1ec4efe4e940dd6ab4eb50dad43d16b422e6655b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 8 May 2019 22:41:40 +0900 Subject: [PATCH 1/2] Replace await! macro with await syntax --- README.md | 8 ++++---- examples/echo.rs | 8 ++++---- examples/http.rs | 6 +++--- src/lib.rs | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6c52401..9be28ec 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ configuration. It exposes the most minimal API possible. ## Example ```rust -#![feature(async_await, await_macro)] +#![feature(async_await)] use std::io; @@ -29,14 +29,14 @@ fn main() -> io::Result<()> { println!("Listening on 127.0.0.1:7878"); - while let Some(stream) = await!(incoming.next()) { + while let Some(stream) = incoming.next().await { let stream = stream?; let addr = stream.peer_addr()?; juliex::spawn(async move { println!("Accepting stream from: {}", addr); - await!(echo_on(stream)).unwrap(); + echo_on(stream).await.unwrap(); println!("Closing stream from: {}", addr); }); @@ -48,7 +48,7 @@ fn main() -> io::Result<()> { async fn echo_on(stream: TcpStream) -> io::Result<()> { let (mut reader, mut writer) = stream.split(); - await!(reader.copy_into(&mut writer))?; + reader.copy_into(&mut writer).await?; Ok(()) } ``` diff --git a/examples/echo.rs b/examples/echo.rs index 112b861..6068e0b 100644 --- a/examples/echo.rs +++ b/examples/echo.rs @@ -1,4 +1,4 @@ -#![feature(async_await, await_macro)] +#![feature(async_await)] use std::io; @@ -15,14 +15,14 @@ fn main() -> io::Result<()> { println!("Listening on 127.0.0.1:7878"); - while let Some(stream) = await!(incoming.next()) { + while let Some(stream) = incoming.next().await { let stream = stream?; let addr = stream.peer_addr()?; juliex::spawn(async move { println!("Accepting stream from: {}", addr); - await!(echo_on(stream)).unwrap(); + echo_on(stream).await.unwrap(); println!("Closing stream from: {}", addr); }); @@ -34,6 +34,6 @@ fn main() -> io::Result<()> { async fn echo_on(stream: TcpStream) -> io::Result<()> { let (mut reader, mut writer) = stream.split(); - await!(reader.copy_into(&mut writer))?; + reader.copy_into(&mut writer).await?; Ok(()) } diff --git a/examples/http.rs b/examples/http.rs index 89c6696..ca63fd7 100644 --- a/examples/http.rs +++ b/examples/http.rs @@ -1,4 +1,4 @@ -#![feature(async_await, await_macro)] +#![feature(async_await)] use std::io; @@ -16,12 +16,12 @@ fn main() -> io::Result<()> { println!("Listening on 127.0.0.1:7878"); - while let Some(stream) = await!(incoming.next()) { + while let Some(stream) = incoming.next().await { let stream = stream?; juliex::spawn(async move { let (_, mut writer) = stream.split(); - await!(writer.write_all(b"HTTP/1.1 200 OK\r\nContent-Length:0\r\n\r\n")).unwrap(); + writer.write_all(b"HTTP/1.1 200 OK\r\nContent-Length:0\r\n\r\n").await.unwrap(); }); } diff --git a/src/lib.rs b/src/lib.rs index 4242967..c0566f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ //! //! ## Example //! ```rust,no_run -//! #![feature(async_await, await_macro)] +//! #![feature(async_await)] //! //! use std::io; //! @@ -29,14 +29,14 @@ //! //! println!("Listening on 127.0.0.1:7878"); //! -//! while let Some(stream) = await!(incoming.next()) { +//! while let Some(stream) = incoming.next().await { //! let stream = stream?; //! let addr = stream.peer_addr()?; //! //! juliex::spawn(async move { //! println!("Accepting stream from: {}", addr); //! -//! await!(echo_on(stream)).unwrap(); +//! echo_on(stream).await.unwrap(); //! //! println!("Closing stream from: {}", addr); //! }); @@ -48,7 +48,7 @@ //! //! async fn echo_on(stream: TcpStream) -> io::Result<()> { //! let (mut reader, mut writer) = stream.split(); -//! await!(reader.copy_into(&mut writer))?; +//! reader.copy_into(&mut writer).await?; //! Ok(()) //! } //! ``` @@ -149,7 +149,7 @@ impl ThreadPool { /// /// ## Example /// ```rust,ignore -/// #![feature(async_await, await_macro)] +/// #![feature(async_await)] /// use std::thread; /// use futures::executor; /// From 66e6dcd15aceedee1643f1b0c79e61fda9eabca4 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 13 May 2019 00:50:48 +0900 Subject: [PATCH 2/2] Update futures-preview to 0.3.0-alpha.16 --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0214b36..3281c2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0" [dependencies] crossbeam = "0.6.0" -futures-preview = "0.3.0-alpha.15" +futures-preview = "0.3.0-alpha.16" num_cpus = "1.9.0" lazy_static = "1.2.0" [dev-dependencies] -romio = "0.3.0-alpha.6" +romio = "0.3.0-alpha.7"