diff --git a/examples/line-count.rs b/examples/line-count.rs index a01cb5e..367789a 100644 --- a/examples/line-count.rs +++ b/examples/line-count.rs @@ -13,9 +13,8 @@ fn main() -> io::Result<()> { let path = args().nth(1).expect("missing path argument"); task::block_on(async { - let file = BufReader::new(File::open(&path).await?); - - let mut lines = file.lines(); + let file = File::open(&path).await?; + let mut lines = BufReader::new(file).lines(); let mut count = 0u64; while let Some(line) = lines.next().await { diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index 7a7b2b6..b6c0ae7 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -14,9 +14,9 @@ #![feature(async_await)] -use async_Std::prelude::*; use async_std::io; use async_std::net::TcpStream; +use async_std::prelude::*; use async_std::task; fn main() -> io::Result<()> { diff --git a/examples/tcp-echo.rs b/examples/tcp-echo.rs index a7238d2..0816439 100644 --- a/examples/tcp-echo.rs +++ b/examples/tcp-echo.rs @@ -8,10 +8,10 @@ #![feature(async_await)] -use async_stD::task; use async_std::io; use async_std::net::{TcpListener, TcpStream}; use async_std::prelude::*; +use async_std::task; async fn process(stream: TcpStream) -> io::Result<()> { println!("Accepted from: {}", stream.peer_addr()?); diff --git a/src/fs/dir_entry.rs b/src/fs/dir_entry.rs index 761f142..b2312c0 100644 --- a/src/fs/dir_entry.rs +++ b/src/fs/dir_entry.rs @@ -158,7 +158,7 @@ impl DirEntry { /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # /// use async_std::fs; - /// use async_Std::prelude::*; + /// use async_std::prelude::*; /// /// let mut dir = fs::read_dir(".").await?; /// diff --git a/src/fs/file.rs b/src/fs/file.rs index 6f6b898..330c61f 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -338,9 +338,8 @@ impl File { /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # /// use async_std::fs::File; - /// use async_std::prelude::*; /// - /// let mut file = File::create("a.txt").await?; + /// let file = File::create("a.txt").await?; /// file.set_len(10).await?; /// # /// # Ok(()) }) } @@ -438,9 +437,9 @@ impl File { /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # /// use async_std::fs::File; - /// use async_std::prelude::*; /// - /// let mut file = File::create("a.txt").await?; + /// let file = File::create("a.txt").await?; + /// /// let mut perms = file.metadata().await?.permissions(); /// perms.set_readonly(true); /// file.set_permissions(perms).await?; diff --git a/src/io/buf_read.rs b/src/io/buf_read.rs index 40ab337..fa010ed 100644 --- a/src/io/buf_read.rs +++ b/src/io/buf_read.rs @@ -53,10 +53,10 @@ pub trait BufRead { /// use async_std::io::BufReader; /// use async_std::prelude::*; /// - /// let mut f = BufReader::new(File::open("a.txt").await?); + /// let mut file = BufReader::new(File::open("a.txt").await?); /// /// let mut buf = vec![0; 1024]; - /// let n = f.read_until(b'\n', &mut buf).await?; + /// let n = file.read_until(b'\n', &mut buf).await?; /// # /// # Ok(()) }) } /// ``` @@ -104,10 +104,10 @@ pub trait BufRead { /// use async_std::io::BufReader; /// use async_std::prelude::*; /// - /// let mut f = BufReader::new(File::open("a.txt").await?); + /// let mut file = BufReader::new(File::open("a.txt").await?); /// /// let mut buf = String::new(); - /// f.read_line(&mut buf).await?; + /// file.read_line(&mut buf).await?; /// # /// # Ok(()) }) } /// ``` @@ -145,9 +145,8 @@ pub trait BufRead { /// use async_std::io::BufReader; /// use async_std::prelude::*; /// - /// let mut f = BufReader::new(File::open("a.txt").await?); - /// - /// let mut lines = f.lines(); + /// let file = File::open("a.txt").await?; + /// let mut lines = BufReader::new(file).lines(); /// let mut count = 0; /// /// for line in lines.next().await { diff --git a/src/io/copy.rs b/src/io/copy.rs index abb45ff..829bf0c 100644 --- a/src/io/copy.rs +++ b/src/io/copy.rs @@ -32,7 +32,6 @@ use crate::io; /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # /// use async_std::io; -/// use async_std::task; /// /// let mut reader: &[u8] = b"hello"; /// let mut writer = io::stdout(); diff --git a/src/lib.rs b/src/lib.rs index ceb58a9..2cefbc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,8 @@ #![feature(async_await)] #![cfg_attr(feature = "docs", feature(doc_cfg))] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] +#![doc(test(attr(deny(rust_2018_idioms, warnings))))] +#![doc(test(attr(allow(unused_extern_crates, unused_variables))))] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] pub mod fs; diff --git a/src/net/mod.rs b/src/net/mod.rs index 00d752f..6ec9439 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -26,7 +26,7 @@ //! socket.send_to(&buf[..n], &peer).await?; //! } //! # -//! # Ok(()) }) } +//! # }) } //! ``` pub use tcp::{Incoming, TcpListener, TcpStream}; diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 9fc9850..04f1c55 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -42,7 +42,7 @@ use crate::task::Poll; /// socket.send_to(&buf[..n], &peer).await?; /// } /// # -/// # Ok(()) }) } +/// # }) } /// ``` #[derive(Debug)] pub struct UdpSocket { @@ -117,8 +117,6 @@ impl UdpSocket { /// # #![feature(async_await)] /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async { /// # - /// use std::net::IpAddr; - /// /// use async_std::net::UdpSocket; /// /// let socket = UdpSocket::bind("127.0.0.1:0").await?; diff --git a/src/os/unix/net/datagram.rs b/src/os/unix/net/datagram.rs index 8886689..8ad24c5 100644 --- a/src/os/unix/net/datagram.rs +++ b/src/os/unix/net/datagram.rs @@ -181,7 +181,7 @@ impl UnixDatagram { /// # /// use async_std::os::unix::net::UnixDatagram; /// - /// let mut socket = UnixDatagram::unbound()?; + /// let socket = UnixDatagram::unbound()?; /// socket.connect("/tmp/socket").await?; /// let peer = socket.peer_addr()?; /// # @@ -203,7 +203,7 @@ impl UnixDatagram { /// # /// use async_std::os::unix::net::UnixDatagram; /// - /// let mut socket = UnixDatagram::unbound()?; + /// let socket = UnixDatagram::unbound()?; /// let mut buf = vec![0; 1024]; /// let (n, peer) = socket.recv_from(&mut buf).await?; /// # @@ -271,7 +271,7 @@ impl UnixDatagram { /// # /// use async_std::os::unix::net::UnixDatagram; /// - /// let mut socket = UnixDatagram::unbound()?; + /// let socket = UnixDatagram::unbound()?; /// socket.send_to(b"hello world", "/tmp/socket").await?; /// # /// # Ok(()) }) } @@ -304,7 +304,7 @@ impl UnixDatagram { /// # /// use async_std::os::unix::net::UnixDatagram; /// - /// let mut socket = UnixDatagram::unbound()?; + /// let socket = UnixDatagram::unbound()?; /// socket.connect("/tmp/socket").await?; /// socket.send(b"hello world").await?; /// # diff --git a/src/sync/rwlock.rs b/src/sync/rwlock.rs index a345ff9..647a3bc 100644 --- a/src/sync/rwlock.rs +++ b/src/sync/rwlock.rs @@ -220,7 +220,7 @@ impl RwLock { /// /// let lock = RwLock::new(1); /// - /// let mut n = lock.read().await; + /// let n = lock.read().await; /// assert_eq!(*n, 1); /// /// assert!(lock.try_read().is_some()); @@ -385,7 +385,7 @@ impl RwLock { /// /// let lock = RwLock::new(1); /// - /// let mut n = lock.read().await; + /// let n = lock.read().await; /// assert_eq!(*n, 1); /// /// assert!(lock.try_write().is_none()); diff --git a/src/task/task.rs b/src/task/task.rs index 834b2ac..03947ae 100644 --- a/src/task/task.rs +++ b/src/task/task.rs @@ -184,7 +184,7 @@ impl Tag { let new = mem::transmute::>(new_raw); drop(new); } - }; + } mem::transmute::<&AtomicUsize, &Option>(&self.raw_metadata) .as_ref()