Cleanup and docs

pull/24/head
Stjepan Glavina 5 years ago
parent d287237f7b
commit e459bd048e

@ -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 {

@ -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<()> {

@ -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()?);

@ -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?;
///

@ -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?;

@ -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 {

@ -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();

@ -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;

@ -26,7 +26,7 @@
//! socket.send_to(&buf[..n], &peer).await?;
//! }
//! #
//! # Ok(()) }) }
//! # }) }
//! ```
pub use tcp::{Incoming, TcpListener, TcpStream};

@ -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?;

@ -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?;
/// #

@ -220,7 +220,7 @@ impl<T> RwLock<T> {
///
/// 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<T> RwLock<T> {
///
/// 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());

@ -184,7 +184,7 @@ impl Tag {
let new = mem::transmute::<usize, Option<Task>>(new_raw);
drop(new);
}
};
}
mem::transmute::<&AtomicUsize, &Option<Task>>(&self.raw_metadata)
.as_ref()

Loading…
Cancel
Save