From 019c8085f4d0a7836fe198644fbafc09054b7c93 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Wed, 14 Aug 2019 03:47:39 +0200 Subject: [PATCH] Cleanup examples --- examples/list-dir.rs | 5 ++++- examples/print-file.rs | 5 ++++- examples/stdin-echo.rs | 4 +++- examples/stdin-timeout.rs | 4 +++- examples/task-local.rs | 3 ++- examples/tcp-client.rs | 5 ++++- examples/tcp-echo.rs | 4 +++- examples/udp-client.rs | 4 +++- examples/udp-echo.rs | 4 +++- src/fs/dir_entry.rs | 12 ++++++++---- src/fs/read_dir.rs | 4 ++-- src/fs/read_to_string.rs | 11 ++++++----- src/fs/set_permissions.rs | 1 - src/future/pending.rs | 3 ++- src/io/buf_read.rs | 12 +++++++++--- src/io/copy.rs | 3 ++- src/io/read.rs | 12 ++++++++---- src/io/seek.rs | 4 +++- src/io/stderr.rs | 3 ++- src/io/stdin.rs | 11 ++++++----- src/io/stdout.rs | 3 ++- src/io/write.rs | 9 ++++++--- src/net/tcp/listener.rs | 7 +++++-- src/net/tcp/stream.rs | 6 ++++-- src/net/udp/mod.rs | 9 ++++++--- src/os/unix/net/mod.rs | 3 ++- src/prelude.rs | 2 ++ src/stream/empty.rs | 3 ++- src/stream/mod.rs | 3 ++- src/stream/once.rs | 3 ++- src/stream/repeat.rs | 3 ++- src/stream/stream.rs | 9 ++++++--- src/sync/mod.rs | 4 +++- src/sync/mutex.rs | 13 +++++++++---- src/task/local.rs | 15 ++++++++++++--- src/task/pool.rs | 4 ++-- src/task/sleep.rs | 3 ++- 37 files changed, 146 insertions(+), 67 deletions(-) diff --git a/examples/list-dir.rs b/examples/list-dir.rs index 545d68d..10c16d1 100644 --- a/examples/list-dir.rs +++ b/examples/list-dir.rs @@ -4,7 +4,10 @@ use std::env::args; -use async_std::{fs, io, prelude::*, task}; +use async_std::fs; +use async_std::io; +use async_std::prelude::*; +use async_std::task; fn main() -> io::Result<()> { let path = args().nth(1).expect("missing path argument"); diff --git a/examples/print-file.rs b/examples/print-file.rs index 49d0244..9c88635 100644 --- a/examples/print-file.rs +++ b/examples/print-file.rs @@ -4,7 +4,10 @@ use std::env::args; -use async_std::{fs::File, io, prelude::*, task}; +use async_std::fs::File; +use async_std::io; +use async_std::prelude::*; +use async_std::task; const LEN: usize = 4 * 1024 * 1024; // 4 Mb diff --git a/examples/stdin-echo.rs b/examples/stdin-echo.rs index e85bcbd..6940654 100644 --- a/examples/stdin-echo.rs +++ b/examples/stdin-echo.rs @@ -2,7 +2,9 @@ #![feature(async_await)] -use async_std::{io, prelude::*, task}; +use async_std::io; +use async_std::prelude::*; +use async_std::task; fn main() -> io::Result<()> { task::block_on(async { diff --git a/examples/stdin-timeout.rs b/examples/stdin-timeout.rs index 188112d..dde49e5 100644 --- a/examples/stdin-timeout.rs +++ b/examples/stdin-timeout.rs @@ -4,7 +4,9 @@ use std::time::Duration; -use async_std::{io, prelude::*, task}; +use async_std::io; +use async_std::prelude::*; +use async_std::task; fn main() -> io::Result<()> { task::block_on(async { diff --git a/examples/task-local.rs b/examples/task-local.rs index ed54180..50e1473 100644 --- a/examples/task-local.rs +++ b/examples/task-local.rs @@ -4,7 +4,8 @@ use std::cell::Cell; -use async_std::{task, task_local}; +use async_std::prelude::*; +use async_std::task; task_local! { static VAR: Cell = Cell::new(1); diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index 83e6a32..7a7b2b6 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -14,7 +14,10 @@ #![feature(async_await)] -use async_std::{io, net::TcpStream, prelude::*, task}; +use async_Std::prelude::*; +use async_std::io; +use async_std::net::TcpStream; +use async_std::task; fn main() -> io::Result<()> { task::block_on(async { diff --git a/examples/tcp-echo.rs b/examples/tcp-echo.rs index 2c192cf..a7238d2 100644 --- a/examples/tcp-echo.rs +++ b/examples/tcp-echo.rs @@ -8,8 +8,10 @@ #![feature(async_await)] +use async_stD::task; +use async_std::io; use async_std::net::{TcpListener, TcpStream}; -use async_std::{io, prelude::*, task}; +use async_std::prelude::*; async fn process(stream: TcpStream) -> io::Result<()> { println!("Accepted from: {}", stream.peer_addr()?); diff --git a/examples/udp-client.rs b/examples/udp-client.rs index defc661..c1a8c92 100644 --- a/examples/udp-client.rs +++ b/examples/udp-client.rs @@ -14,7 +14,9 @@ #![feature(async_await)] -use async_std::{io, net::UdpSocket, task}; +use async_std::io; +use async_std::net::UdpSocket; +use async_std::task; fn main() -> io::Result<()> { task::block_on(async { diff --git a/examples/udp-echo.rs b/examples/udp-echo.rs index 5bb0bb4..0d17c00 100644 --- a/examples/udp-echo.rs +++ b/examples/udp-echo.rs @@ -8,7 +8,9 @@ #![feature(async_await)] -use async_std::{io, net::UdpSocket, task}; +use async_std::io; +use async_std::net::UdpSocket; +use async_std::task; fn main() -> io::Result<()> { task::block_on(async { diff --git a/src/fs/dir_entry.rs b/src/fs/dir_entry.rs index 105f22e..761f142 100644 --- a/src/fs/dir_entry.rs +++ b/src/fs/dir_entry.rs @@ -77,7 +77,8 @@ impl DirEntry { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs, prelude::*}; + /// use async_std::fs; + /// use async_std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// @@ -102,7 +103,8 @@ impl DirEntry { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs, prelude::*}; + /// use async_std::fs; + /// use async_std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// @@ -155,7 +157,8 @@ impl DirEntry { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs, prelude::*}; + /// use async_std::fs; + /// use async_Std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// @@ -206,7 +209,8 @@ impl DirEntry { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs, prelude::*}; + /// use async_std::fs; + /// use async_std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// diff --git a/src/fs/read_dir.rs b/src/fs/read_dir.rs index 0492373..7bdd532 100644 --- a/src/fs/read_dir.rs +++ b/src/fs/read_dir.rs @@ -1,5 +1,4 @@ use std::fs; - use std::path::Path; use std::pin::Pin; use std::sync::Mutex; @@ -34,7 +33,8 @@ use crate::task::{blocking, Context, Poll}; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{fs, prelude::*}; +/// use async_std::fs; +/// use async_std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// diff --git a/src/fs/read_to_string.rs b/src/fs/read_to_string.rs index 2f771fa..b6bd858 100644 --- a/src/fs/read_to_string.rs +++ b/src/fs/read_to_string.rs @@ -21,12 +21,13 @@ use crate::task::blocking; /// /// ```no_run /// # #![feature(async_await)] -/// use async_std::fs::read_to_string; +/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { +/// # +/// use async_std::fs; /// -/// # futures::executor::block_on(async { -/// let contents = read_to_string("a.txt").await?; -/// # std::io::Result::Ok(()) -/// # }).unwrap(); +/// let contents = fs::read_to_string("a.txt").await?; +/// # +/// # Ok(()) }) } /// ``` pub async fn read_to_string>(path: P) -> io::Result { let path = path.as_ref().to_owned(); diff --git a/src/fs/set_permissions.rs b/src/fs/set_permissions.rs index e5e1c2a..9634221 100644 --- a/src/fs/set_permissions.rs +++ b/src/fs/set_permissions.rs @@ -27,7 +27,6 @@ use crate::task::blocking; /// /// let mut perm = fs::metadata("a.txt").await?.permissions(); /// perm.set_readonly(true); -/// /// fs::set_permissions("a.txt", perm).await?; /// # /// # Ok(()) }) } diff --git a/src/future/pending.rs b/src/future/pending.rs index f1ec26e..f45199f 100644 --- a/src/future/pending.rs +++ b/src/future/pending.rs @@ -5,9 +5,10 @@ /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # +/// use std::time::Duration; +/// /// use async_std::future::pending; /// use async_std::prelude::*; -/// use std::time::Duration; /// /// let dur = Duration::from_secs(1); /// assert!(pending::<()>().timeout(dur).await.is_err()); diff --git a/src/io/buf_read.rs b/src/io/buf_read.rs index 6253037..40ab337 100644 --- a/src/io/buf_read.rs +++ b/src/io/buf_read.rs @@ -49,7 +49,9 @@ pub trait BufRead { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, io::BufReader, prelude::*}; + /// use async_std::fs::File; + /// use async_std::io::BufReader; + /// use async_std::prelude::*; /// /// let mut f = BufReader::new(File::open("a.txt").await?); /// @@ -98,7 +100,9 @@ pub trait BufRead { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, io::BufReader, prelude::*}; + /// use async_std::fs::File; + /// use async_std::io::BufReader; + /// use async_std::prelude::*; /// /// let mut f = BufReader::new(File::open("a.txt").await?); /// @@ -137,7 +141,9 @@ pub trait BufRead { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, io::BufReader, prelude::*}; + /// use async_std::fs::File; + /// use async_std::io::BufReader; + /// use async_std::prelude::*; /// /// let mut f = BufReader::new(File::open("a.txt").await?); /// diff --git a/src/io/copy.rs b/src/io/copy.rs index 01894e8..abb45ff 100644 --- a/src/io/copy.rs +++ b/src/io/copy.rs @@ -31,7 +31,8 @@ use crate::io; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{io, task}; +/// use async_std::io; +/// use async_std::task; /// /// let mut reader: &[u8] = b"hello"; /// let mut writer = io::stdout(); diff --git a/src/io/read.rs b/src/io/read.rs index ff3dc33..d33ec0f 100644 --- a/src/io/read.rs +++ b/src/io/read.rs @@ -55,7 +55,8 @@ pub trait Read { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::open("a.txt").await?; /// @@ -104,7 +105,8 @@ pub trait Read { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::open("a.txt").await?; /// @@ -141,7 +143,8 @@ pub trait Read { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::open("a.txt").await?; /// @@ -193,7 +196,8 @@ pub trait Read { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::open("a.txt").await?; /// diff --git a/src/io/seek.rs b/src/io/seek.rs index 110642c..49aaed1 100644 --- a/src/io/seek.rs +++ b/src/io/seek.rs @@ -47,7 +47,9 @@ pub trait Seek { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, io::SeekFrom, prelude::*}; + /// use async_std::fs::File; + /// use async_std::io::SeekFrom; + /// use async_std::prelude::*; /// /// let mut f = File::open("a.txt").await?; /// diff --git a/src/io/stderr.rs b/src/io/stderr.rs index 354a958..9983f61 100644 --- a/src/io/stderr.rs +++ b/src/io/stderr.rs @@ -19,7 +19,8 @@ use crate::task::{blocking, Context, Poll}; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{io, prelude::*}; +/// use async_std::io; +/// use async_std::prelude::*; /// /// let mut stderr = io::stderr(); /// stderr.write_all(b"Hello, world!").await?; diff --git a/src/io/stdin.rs b/src/io/stdin.rs index 4449e21..8747e7e 100644 --- a/src/io/stdin.rs +++ b/src/io/stdin.rs @@ -93,14 +93,15 @@ impl Stdin { /// /// ```no_run /// # #![feature(async_await)] - /// use async_std::io::stdin; + /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { + /// # + /// use async_std::io; /// - /// # futures::executor::block_on(async { - /// let stdin = stdin(); + /// let stdin = io::stdin(); /// let mut line = String::new(); /// stdin.read_line(&mut line).await?; - /// # std::io::Result::Ok(()) - /// # }).unwrap(); + /// # + /// # Ok(()) }) } /// ``` pub async fn read_line(&self, buf: &mut String) -> io::Result { future::poll_fn(|cx| { diff --git a/src/io/stdout.rs b/src/io/stdout.rs index 0911646..9100f24 100644 --- a/src/io/stdout.rs +++ b/src/io/stdout.rs @@ -19,7 +19,8 @@ use crate::task::{blocking, Context, Poll}; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{io, prelude::*}; +/// use async_std::io; +/// use async_std::prelude::*; /// /// let mut stdout = io::stdout(); /// stdout.write_all(b"Hello, world!").await?; diff --git a/src/io/write.rs b/src/io/write.rs index 9e90588..356aee6 100644 --- a/src/io/write.rs +++ b/src/io/write.rs @@ -50,7 +50,8 @@ pub trait Write { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::create("a.txt").await?; /// @@ -70,7 +71,8 @@ pub trait Write { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::create("a.txt").await?; /// @@ -115,7 +117,8 @@ pub trait Write { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{fs::File, prelude::*}; + /// use async_std::fs::File; + /// use async_std::prelude::*; /// /// let mut f = File::create("a.txt").await?; /// diff --git a/src/net/tcp/listener.rs b/src/net/tcp/listener.rs index 32a67a8..e85d90b 100644 --- a/src/net/tcp/listener.rs +++ b/src/net/tcp/listener.rs @@ -33,7 +33,9 @@ use crate::task::{Context, Poll}; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{io, net::TcpListener, prelude::*}; +/// use async_std::io; +/// use async_std::net::TcpListener; +/// use async_std::prelude::*; /// /// let listener = TcpListener::bind("127.0.0.1:8080").await?; /// let mut incoming = listener.incoming(); @@ -173,7 +175,8 @@ impl TcpListener { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::{net::TcpListener, prelude::*}; + /// use async_std::net::TcpListener; + /// use async_std::prelude::*; /// /// let listener = TcpListener::bind("127.0.0.1:0").await?; /// let mut incoming = listener.incoming(); diff --git a/src/net/tcp/stream.rs b/src/net/tcp/stream.rs index 2a36ae5..234467a 100644 --- a/src/net/tcp/stream.rs +++ b/src/net/tcp/stream.rs @@ -36,7 +36,8 @@ use crate::task::{Context, Poll}; /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # -/// use async_std::{net::TcpStream, prelude::*}; +/// use async_std::net::TcpStream; +/// use async_std::prelude::*; /// /// let mut stream = TcpStream::connect("127.0.0.1:8080").await?; /// stream.write_all(b"hello world").await?; @@ -340,9 +341,10 @@ impl TcpStream { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::net::TcpStream; /// use std::net::Shutdown; /// + /// use async_std::net::TcpStream; + /// /// let stream = TcpStream::connect("127.0.0.1:8080").await?; /// stream.shutdown(Shutdown::Both)?; /// # diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 50774d6..9fc9850 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -117,9 +117,10 @@ impl UdpSocket { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::net::UdpSocket; /// use std::net::IpAddr; /// + /// use async_std::net::UdpSocket; + /// /// let socket = UdpSocket::bind("127.0.0.1:0").await?; /// let addr = socket.local_addr()?; /// # @@ -446,9 +447,10 @@ impl UdpSocket { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::net::UdpSocket; /// use std::net::Ipv4Addr; /// + /// use async_std::net::UdpSocket; + /// /// let interface = Ipv4Addr::new(0, 0, 0, 0); /// let mdns_addr = Ipv4Addr::new(224, 0, 0, 123); /// @@ -475,9 +477,10 @@ impl UdpSocket { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use async_std::net::UdpSocket; /// use std::net::{Ipv6Addr, SocketAddr}; /// + /// use async_std::net::UdpSocket; + /// /// let socket_addr = SocketAddr::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0).into(), 0); /// let mdns_addr = Ipv6Addr::new(0xFF02, 0, 0, 0, 0, 0, 0, 0x0123) ; /// let socket = UdpSocket::bind(&socket_addr).await?; diff --git a/src/os/unix/net/mod.rs b/src/os/unix/net/mod.rs index 45062c4..1597948 100644 --- a/src/os/unix/net/mod.rs +++ b/src/os/unix/net/mod.rs @@ -65,9 +65,10 @@ cfg_if! { /// With a pathname: /// /// ```no_run - /// use async_std::os::unix::net::UnixListener; /// use std::path::Path; /// + /// use async_std::os::unix::net::UnixListener; + /// /// let socket = UnixListener::bind("/tmp/socket").await?; /// let addr = socket.local_addr()?; /// assert_eq!(addr.as_pathname(), Some(Path::new("/tmp/socket"))); diff --git a/src/prelude.rs b/src/prelude.rs index 1f35312..90df8e5 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -37,4 +37,6 @@ pub use crate::io::Write as _; #[doc(no_inline)] pub use crate::stream::Stream; #[doc(no_inline)] +pub use crate::task_local; +#[doc(no_inline)] pub use crate::time::Timeout as _; diff --git a/src/stream/empty.rs b/src/stream/empty.rs index eed6064..c03146e 100644 --- a/src/stream/empty.rs +++ b/src/stream/empty.rs @@ -11,7 +11,8 @@ use crate::task::{Context, Poll}; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::{prelude::*, stream}; +/// use async_std::prelude::*; +/// use async_std::stream; /// /// let mut s = stream::empty::(); /// diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 5100ede..a760a9b 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -10,7 +10,8 @@ //! # #![feature(async_await)] //! # fn main() { async_std::task::block_on(async { //! # -//! use async_std::{prelude::*, stream}; +//! use async_std::prelude::*; +//! use async_std::stream; //! //! let mut s = stream::repeat(9).take(3); //! diff --git a/src/stream/once.rs b/src/stream/once.rs index 36a6eba..7c1e45b 100644 --- a/src/stream/once.rs +++ b/src/stream/once.rs @@ -10,7 +10,8 @@ use crate::task::{Context, Poll}; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::{prelude::*, stream}; +/// use async_std::prelude::*; +/// use async_std::stream; /// /// let mut s = stream::once(7); /// diff --git a/src/stream/repeat.rs b/src/stream/repeat.rs index 84847c4..4b4b442 100644 --- a/src/stream/repeat.rs +++ b/src/stream/repeat.rs @@ -10,7 +10,8 @@ use crate::task::{Context, Poll}; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::{prelude::*, stream}; +/// use async_std::prelude::*; +/// use async_std::stream; /// /// let mut s = stream::repeat(7); /// diff --git a/src/stream/stream.rs b/src/stream/stream.rs index 62e9f4e..4421d31 100644 --- a/src/stream/stream.rs +++ b/src/stream/stream.rs @@ -10,7 +10,8 @@ //! # #![feature(async_await)] //! # fn main() { async_std::task::block_on(async { //! # -//! use async_std::{prelude::*, stream}; +//! use async_std::prelude::*; +//! use async_std::stream; //! //! let mut s = stream::repeat(9).take(3); //! @@ -71,7 +72,8 @@ pub trait Stream { /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # - /// use async_std::{prelude::*, stream}; + /// use async_std::prelude::*; + /// use async_std::stream; /// /// let mut s = stream::once(7); /// @@ -92,7 +94,8 @@ pub trait Stream { /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # - /// use async_std::{prelude::*, stream}; + /// use async_std::prelude::*; + /// use async_std::stream; /// /// let mut s = stream::repeat(9).take(3); /// diff --git a/src/sync/mod.rs b/src/sync/mod.rs index ae27f89..1a4b068 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -12,9 +12,11 @@ //! # #![feature(async_await)] //! # fn main() { async_std::task::block_on(async { //! # -//! use async_std::{sync::Mutex, task}; //! use std::sync::Arc; //! +//! use async_std::sync::Mutex; +//! use async_std::task; +//! //! let m1 = Arc::new(Mutex::new(0)); //! let m2 = m1.clone(); //! diff --git a/src/sync/mutex.rs b/src/sync/mutex.rs index d629a29..d0f110b 100644 --- a/src/sync/mutex.rs +++ b/src/sync/mutex.rs @@ -27,9 +27,11 @@ const BLOCKED: usize = 1 << 1; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::{sync::Mutex, task}; /// use std::sync::Arc; /// +/// use async_std::sync::Mutex; +/// use async_std::task; +/// /// let m = Arc::new(Mutex::new(0)); /// let mut tasks = vec![]; /// @@ -84,9 +86,11 @@ impl Mutex { /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # - /// use async_std::{sync::Mutex, task}; /// use std::sync::Arc; /// + /// use async_std::sync::Mutex; + /// use async_std::task; + /// /// let m1 = Arc::new(Mutex::new(10)); /// let m2 = m1.clone(); /// @@ -197,9 +201,11 @@ impl Mutex { /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # - /// use async_std::{sync::Mutex, task}; /// use std::sync::Arc; /// + /// use async_std::sync::Mutex; + /// use async_std::task; + /// /// let m1 = Arc::new(Mutex::new(10)); /// let m2 = m1.clone(); /// @@ -229,7 +235,6 @@ impl Mutex { /// # Examples /// /// ``` - /// # #![feature(async_await)] /// use async_std::sync::Mutex; /// /// let mutex = Mutex::new(10); diff --git a/src/task/local.rs b/src/task/local.rs index f853a83..eb34801 100644 --- a/src/task/local.rs +++ b/src/task/local.rs @@ -21,9 +21,12 @@ use super::pool; /// /// ``` /// # #![feature(async_await)] -/// use async_std::{task, task_local}; +/// # /// use std::cell::Cell; /// +/// use async_std::task; +/// use async_std::prelude::*; +/// /// task_local! { /// static VAL: Cell = Cell::new(5); /// } @@ -90,9 +93,12 @@ impl LocalKey { /// /// ``` /// # #![feature(async_await)] - /// use async_std::{task, task_local}; + /// # /// use std::cell::Cell; /// + /// use async_std::task; + /// use async_std::prelude::*; + /// /// task_local! { /// static NUMBER: Cell = Cell::new(5); /// } @@ -127,9 +133,12 @@ impl LocalKey { /// /// ``` /// # #![feature(async_await)] - /// use async_std::{task, task_local}; + /// # /// use std::cell::Cell; /// + /// use async_std::task; + /// use async_std::prelude::*; + /// /// task_local! { /// static VAL: Cell = Cell::new(5); /// } diff --git a/src/task/pool.rs b/src/task/pool.rs index 1f36bb0..331b03c 100644 --- a/src/task/pool.rs +++ b/src/task/pool.rs @@ -32,9 +32,9 @@ use crate::io; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::task::current; +/// use async_std::task; /// -/// println!("The name of this task is {:?}", current().name()); +/// println!("The name of this task is {:?}", task::current().name()); /// # /// # }) } /// ``` diff --git a/src/task/sleep.rs b/src/task/sleep.rs index 2739d87..a0392be 100644 --- a/src/task/sleep.rs +++ b/src/task/sleep.rs @@ -18,9 +18,10 @@ use crate::time::Timeout; /// # #![feature(async_await)] /// # fn main() { async_std::task::block_on(async { /// # -/// use async_std::task; /// use std::time::Duration; /// +/// use async_std::task; +/// /// task::sleep(Duration::from_secs(1)).await; /// # /// # }) }