diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..6553e5c --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,2 @@ +# https://github.com/rust-lang/async-book/pull/59#issuecomment-556240879 +disable_all_formatting = true diff --git a/examples/01_02_why_async/src/lib.rs b/examples/01_02_why_async/src/lib.rs index 64758e4..f2ecba9 100644 --- a/examples/01_02_why_async/src/lib.rs +++ b/examples/01_02_why_async/src/lib.rs @@ -1,12 +1,7 @@ #![cfg(test)] -use { - futures::{ - executor::block_on, - join, - }, - std::thread, -}; +use futures::{executor::block_on, join}; +use std::thread; fn download(_url: &str) { // ... diff --git a/examples/02_04_executor/src/lib.rs b/examples/02_04_executor/src/lib.rs index 7ab229e..13dadb7 100644 --- a/examples/02_04_executor/src/lib.rs +++ b/examples/02_04_executor/src/lib.rs @@ -1,21 +1,19 @@ #![cfg(test)] // ANCHOR: imports -use { - futures::{ - future::{BoxFuture, FutureExt}, - task::{waker_ref, ArcWake}, - }, - std::{ - future::Future, - sync::mpsc::{sync_channel, Receiver, SyncSender}, - sync::{Arc, Mutex}, - task::Context, - time::Duration, - }, - // The timer we wrote in the previous section: - timer_future::TimerFuture, +use futures::{ + future::{BoxFuture, FutureExt}, + task::{waker_ref, ArcWake}, }; +use std::{ + future::Future, + sync::mpsc::{sync_channel, Receiver, SyncSender}, + sync::{Arc, Mutex}, + task::Context, + time::Duration, +}; +// The timer we wrote in the previous section: +use timer_future::TimerFuture; // ANCHOR_END: imports // ANCHOR: executor_decl diff --git a/examples/05_01_streams/src/lib.rs b/examples/05_01_streams/src/lib.rs index d68fc7e..d560373 100644 --- a/examples/05_01_streams/src/lib.rs +++ b/examples/05_01_streams/src/lib.rs @@ -1,12 +1,10 @@ #![cfg(test)] mod stream_trait { -use { - futures::stream::{Stream as RealStream}, - std::{ - pin::Pin, - task::{Context, Poll}, - }, +use futures::stream::Stream as RealStream; +use std::{ + pin::Pin, + task::{Context, Poll}, }; // ANCHOR: stream_trait @@ -34,11 +32,9 @@ impl Stream for dyn RealStream { } mod channels { -use { - futures::{ - channel::mpsc, - prelude::*, - }, +use futures::{ + channel::mpsc, + prelude::*, }; // ANCHOR: channels diff --git a/examples/05_02_iteration_and_concurrency/src/lib.rs b/examples/05_02_iteration_and_concurrency/src/lib.rs index 6eb36a1..71a463c 100644 --- a/examples/05_02_iteration_and_concurrency/src/lib.rs +++ b/examples/05_02_iteration_and_concurrency/src/lib.rs @@ -1,14 +1,12 @@ #![cfg(test)] -use { - futures::{ - executor::block_on, - stream::{self, Stream}, - }, - std::{ - io, - pin::Pin, - }, +use futures::{ + executor::block_on, + stream::{self, Stream}, +}; +use std::{ + io, + pin::Pin, }; // ANCHOR: nexts diff --git a/examples/09_05_final_tcp_server/src/main.rs b/examples/09_05_final_tcp_server/src/main.rs index 2252061..62e9fef 100644 --- a/examples/09_05_final_tcp_server/src/main.rs +++ b/examples/09_05_final_tcp_server/src/main.rs @@ -21,7 +21,6 @@ async fn main() { // ANCHOR_END: main_func use async_std::io::{Read, Write}; -use std::marker::Unpin; async fn handle_connection(mut stream: impl Read + Write + Unpin) { let mut buffer = [0; 1024]; @@ -90,7 +89,6 @@ mod tests { // ANCHOR_END: mock_write // ANCHOR: unpin - use std::marker::Unpin; impl Unpin for MockTcpStream {} // ANCHOR_END: unpin diff --git a/src/09_example/03_tests.md b/src/09_example/03_tests.md index cbb9b69..be2c0cc 100644 --- a/src/09_example/03_tests.md +++ b/src/09_example/03_tests.md @@ -17,7 +17,6 @@ First, we'll change the signature of `handle_connection` to make it easier to te it requires any struct that implements `async_std::io::Read`, `async_std::io::Write`, and `marker::Unpin`. Changing the type signature to reflect this allows us to pass a mock for testing. ```rust,ignore -use std::marker::Unpin; use async_std::io::{Read, Write}; async fn handle_connection(mut stream: impl Read + Write + Unpin) {