forked from mirror/async-std
Cleanup
This commit is contained in:
parent
01aac21386
commit
1f9628d8ad
15 changed files with 35 additions and 35 deletions
|
@ -32,7 +32,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let bytes_copied = fs::copy("foo.txt", "bar.txt").await?;
|
||||
/// let bytes_copied = fs::copy("a.txt", "b.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -39,7 +39,7 @@ use crate::task::{blocking, Context, Poll};
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::create("foo.txt").await?;
|
||||
/// let mut file = File::create("a.txt").await?;
|
||||
/// file.write_all(b"Hello, world!").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -54,7 +54,7 @@ use crate::task::{blocking, Context, Poll};
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::open("foo.txt").await?;
|
||||
/// let mut file = File::open("a.txt").await?;
|
||||
/// let mut contents = Vec::new();
|
||||
/// file.read_to_end(&mut contents).await?;
|
||||
/// #
|
||||
|
@ -129,7 +129,7 @@ impl File {
|
|||
/// #
|
||||
/// use async_std::fs::File;
|
||||
///
|
||||
/// let file = File::open("foo.txt").await?;
|
||||
/// let file = File::open("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
@ -176,7 +176,7 @@ impl File {
|
|||
/// #
|
||||
/// use async_std::fs::File;
|
||||
///
|
||||
/// let file = File::create("foo.txt").await?;
|
||||
/// let file = File::create("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
@ -224,7 +224,7 @@ impl File {
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::create("foo.txt").await?;
|
||||
/// let mut file = File::create("a.txt").await?;
|
||||
/// file.write_all(b"Hello, world!").await?;
|
||||
/// file.sync_all().await?;
|
||||
/// #
|
||||
|
@ -280,7 +280,7 @@ impl File {
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::create("foo.txt").await?;
|
||||
/// let mut file = File::create("a.txt").await?;
|
||||
/// file.write_all(b"Hello, world!").await?;
|
||||
/// file.sync_data().await?;
|
||||
/// #
|
||||
|
@ -340,7 +340,7 @@ impl File {
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::create("foo.txt").await?;
|
||||
/// let mut file = File::create("a.txt").await?;
|
||||
/// file.set_len(10).await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -387,7 +387,7 @@ impl File {
|
|||
/// #
|
||||
/// use async_std::fs::File;
|
||||
///
|
||||
/// let file = File::open("foo.txt").await?;
|
||||
/// let file = File::open("a.txt").await?;
|
||||
/// let metadata = file.metadata().await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -440,7 +440,7 @@ impl File {
|
|||
/// use async_std::fs::File;
|
||||
/// use async_std::prelude::*;
|
||||
///
|
||||
/// let mut file = File::create("foo.txt").await?;
|
||||
/// let mut file = File::create("a.txt").await?;
|
||||
/// let mut perms = file.metadata().await?.permissions();
|
||||
/// perms.set_readonly(true);
|
||||
/// file.set_permissions(perms).await?;
|
||||
|
|
|
@ -27,7 +27,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let perm = fs::metadata("foo.txt").await?.permissions();
|
||||
/// let perm = fs::metadata("a.txt").await?.permissions();
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//! use async_std::fs::File;
|
||||
//! use async_std::prelude::*;
|
||||
//!
|
||||
//! let mut file = File::create("foo.txt").await?;
|
||||
//! let mut file = File::create("a.txt").await?;
|
||||
//! file.write_all(b"Hello, world!").await?;
|
||||
//! #
|
||||
//! # Ok(()) }) }
|
||||
|
|
|
@ -39,7 +39,7 @@ use crate::task::blocking;
|
|||
///
|
||||
/// let file = OpenOptions::new()
|
||||
/// .read(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -57,7 +57,7 @@ use crate::task::blocking;
|
|||
/// .read(true)
|
||||
/// .write(true)
|
||||
/// .create(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -80,7 +80,7 @@ impl OpenOptions {
|
|||
///
|
||||
/// let file = OpenOptions::new()
|
||||
/// .read(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -103,7 +103,7 @@ impl OpenOptions {
|
|||
///
|
||||
/// let file = OpenOptions::new()
|
||||
/// .read(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -130,7 +130,7 @@ impl OpenOptions {
|
|||
///
|
||||
/// let file = OpenOptions::new()
|
||||
/// .write(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -176,7 +176,7 @@ impl OpenOptions {
|
|||
///
|
||||
/// let file = OpenOptions::new()
|
||||
/// .append(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -204,7 +204,7 @@ impl OpenOptions {
|
|||
/// let file = OpenOptions::new()
|
||||
/// .write(true)
|
||||
/// .truncate(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -234,7 +234,7 @@ impl OpenOptions {
|
|||
/// let file = OpenOptions::new()
|
||||
/// .write(true)
|
||||
/// .create(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -271,7 +271,7 @@ impl OpenOptions {
|
|||
/// let file = OpenOptions::new()
|
||||
/// .write(true)
|
||||
/// .create_new(true)
|
||||
/// .open("foo.txt")
|
||||
/// .open("a.txt")
|
||||
/// .await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
|
@ -321,7 +321,7 @@ impl OpenOptions {
|
|||
/// #
|
||||
/// use async_std::fs::OpenOptions;
|
||||
///
|
||||
/// let file = OpenOptions::new().open("foo.txt").await?;
|
||||
/// let file = OpenOptions::new().open("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -29,7 +29,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let contents = fs::read("foo.txt").await?;
|
||||
/// let contents = fs::read("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let path = fs::read_link("foo.txt").await?;
|
||||
/// let path = fs::read_link("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -24,7 +24,7 @@ use crate::task::blocking;
|
|||
/// use async_std::fs::read_to_string;
|
||||
///
|
||||
/// # futures::executor::block_on(async {
|
||||
/// let contents = read_to_string("foo.txt").await?;
|
||||
/// let contents = read_to_string("a.txt").await?;
|
||||
/// # std::io::Result::Ok(())
|
||||
/// # }).unwrap();
|
||||
/// ```
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// fs::remove_file("foo.txt").await?;
|
||||
/// fs::remove_file("a.txt").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -25,10 +25,10 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let mut perm = fs::metadata("foo.txt").await?.permissions();
|
||||
/// let mut perm = fs::metadata("a.txt").await?.permissions();
|
||||
/// perm.set_readonly(true);
|
||||
///
|
||||
/// fs::set_permissions("foo.txt", perm).await?;
|
||||
/// fs::set_permissions("a.txt", perm).await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// let perm = fs::symlink_metadata("foo.txt").await?.permissions();
|
||||
/// let perm = fs::symlink_metadata("a.txt").await?.permissions();
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -27,7 +27,7 @@ use crate::task::blocking;
|
|||
/// #
|
||||
/// use async_std::fs;
|
||||
///
|
||||
/// fs::write("foo.txt", b"Lorem ipsum").await?;
|
||||
/// fs::write("a.txt", b"Lorem ipsum").await?;
|
||||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Asynchronous standard library.
|
||||
//! Async version of the Rust standard library.
|
||||
//!
|
||||
//! This crate is an async version of [`std`].
|
||||
//!
|
||||
|
|
|
@ -94,11 +94,11 @@ impl<T: Send + 'static> LocalKey<T> {
|
|||
/// use std::cell::Cell;
|
||||
///
|
||||
/// task_local! {
|
||||
/// static FOO: Cell<u32> = Cell::new(5);
|
||||
/// static NUMBER: Cell<u32> = Cell::new(5);
|
||||
/// }
|
||||
///
|
||||
/// task::block_on(async {
|
||||
/// let v = FOO.with(|c| c.get());
|
||||
/// let v = NUMBER.with(|c| c.get());
|
||||
/// assert_eq!(v, 5);
|
||||
/// });
|
||||
/// ```
|
||||
|
|
|
@ -9,10 +9,10 @@ fn smoke() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic = "foo"]
|
||||
#[should_panic = "boom"]
|
||||
fn panic() {
|
||||
task::block_on(async {
|
||||
// This panic should get propagated into the parent thread.
|
||||
panic!("foo");
|
||||
panic!("boom");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue