feat: Stabilize io::Std*Lock

mio-0-7
k-nasa 5 years ago
parent 9167d42f4b
commit 23b7c174f3

@ -309,9 +309,9 @@ cfg_default! {
#[doc(hidden)] #[doc(hidden)]
pub use stdio::{_eprint, _print}; pub use stdio::{_eprint, _print};
pub use stderr::{stderr, Stderr}; pub use stderr::{stderr, Stderr, StderrLock};
pub use stdin::{stdin, Stdin}; pub use stdin::{stdin, Stdin, StdinLock};
pub use stdout::{stdout, Stdout}; pub use stdout::{stdout, Stdout, StdoutLock};
pub use timeout::timeout; pub use timeout::timeout;
mod timeout; mod timeout;
@ -320,9 +320,3 @@ cfg_default! {
mod stdio; mod stdio;
mod stdout; mod stdout;
} }
cfg_unstable_default! {
pub use stderr::StderrLock;
pub use stdin::StdinLock;
pub use stdout::StdoutLock;
}

@ -1,14 +1,12 @@
use std::pin::Pin; use std::pin::Pin;
use std::sync::Mutex; use std::sync::Mutex;
use std::future::Future; use std::future::Future;
use std::io::Write as _;
use crate::io::{self, Write}; use crate::io::{self, Write};
use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; use crate::task::{spawn_blocking, Context, JoinHandle, Poll};
cfg_unstable! { use once_cell::sync::Lazy;
use once_cell::sync::Lazy;
use std::io::Write as _;
}
/// Constructs a new handle to the standard error of the current process. /// Constructs a new handle to the standard error of the current process.
/// ///
@ -65,13 +63,9 @@ pub struct Stderr(Mutex<State>);
/// ///
/// [`Write`]: trait.Read.html /// [`Write`]: trait.Read.html
/// [`Stderr::lock`]: struct.Stderr.html#method.lock /// [`Stderr::lock`]: struct.Stderr.html#method.lock
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)] #[derive(Debug)]
pub struct StderrLock<'a>(std::io::StderrLock<'a>); pub struct StderrLock<'a>(std::io::StderrLock<'a>);
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StderrLock<'_> {} unsafe impl Send for StderrLock<'_> {}
/// The state of the asynchronous stderr. /// The state of the asynchronous stderr.
@ -128,8 +122,6 @@ impl Stderr {
/// # /// #
/// # Ok(()) }) } /// # Ok(()) }) }
/// ``` /// ```
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(any(feature = "unstable", feature = "docs"))]
pub async fn lock(&self) -> StderrLock<'static> { pub async fn lock(&self) -> StderrLock<'static> {
static STDERR: Lazy<std::io::Stderr> = Lazy::new(std::io::stderr); static STDERR: Lazy<std::io::Stderr> = Lazy::new(std::io::stderr);
@ -240,8 +232,6 @@ cfg_windows! {
} }
} }
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl io::Write for StderrLock<'_> { impl io::Write for StderrLock<'_> {
fn poll_write( fn poll_write(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,

@ -1,16 +1,14 @@
use std::future::Future; use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::sync::Mutex; use std::sync::Mutex;
use std::io::Read as _;
use crate::future; use crate::future;
use crate::io::{self, Read}; use crate::io::{self, Read};
use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; use crate::task::{spawn_blocking, Context, JoinHandle, Poll};
use crate::utils::Context as _; use crate::utils::Context as _;
cfg_unstable! { use once_cell::sync::Lazy;
use once_cell::sync::Lazy;
use std::io::Read as _;
}
/// Constructs a new handle to the standard input of the current process. /// Constructs a new handle to the standard input of the current process.
/// ///
@ -67,13 +65,9 @@ pub struct Stdin(Mutex<State>);
/// ///
/// [`Read`]: trait.Read.html /// [`Read`]: trait.Read.html
/// [`Stdin::lock`]: struct.Stdin.html#method.lock /// [`Stdin::lock`]: struct.Stdin.html#method.lock
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(feature = "unstable")]
#[derive(Debug)] #[derive(Debug)]
pub struct StdinLock<'a>(std::io::StdinLock<'a>); pub struct StdinLock<'a>(std::io::StdinLock<'a>);
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StdinLock<'_> {} unsafe impl Send for StdinLock<'_> {}
/// The state of the asynchronous stdin. /// The state of the asynchronous stdin.
@ -187,8 +181,6 @@ impl Stdin {
/// # /// #
/// # Ok(()) }) } /// # Ok(()) }) }
/// ``` /// ```
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(any(feature = "unstable", feature = "docs"))]
pub async fn lock(&self) -> StdinLock<'static> { pub async fn lock(&self) -> StdinLock<'static> {
static STDIN: Lazy<std::io::Stdin> = Lazy::new(std::io::stdin); static STDIN: Lazy<std::io::Stdin> = Lazy::new(std::io::stdin);
@ -266,8 +258,6 @@ cfg_windows! {
} }
} }
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl Read for StdinLock<'_> { impl Read for StdinLock<'_> {
fn poll_read( fn poll_read(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,

@ -1,14 +1,12 @@
use std::pin::Pin; use std::pin::Pin;
use std::sync::Mutex; use std::sync::Mutex;
use std::future::Future; use std::future::Future;
use std::io::Write as _;
use crate::io::{self, Write}; use crate::io::{self, Write};
use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; use crate::task::{spawn_blocking, Context, JoinHandle, Poll};
cfg_unstable! { use once_cell::sync::Lazy;
use once_cell::sync::Lazy;
use std::io::Write as _;
}
/// Constructs a new handle to the standard output of the current process. /// Constructs a new handle to the standard output of the current process.
/// ///
@ -65,13 +63,9 @@ pub struct Stdout(Mutex<State>);
/// ///
/// [`Write`]: trait.Read.html /// [`Write`]: trait.Read.html
/// [`Stdout::lock`]: struct.Stdout.html#method.lock /// [`Stdout::lock`]: struct.Stdout.html#method.lock
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)] #[derive(Debug)]
pub struct StdoutLock<'a>(std::io::StdoutLock<'a>); pub struct StdoutLock<'a>(std::io::StdoutLock<'a>);
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StdoutLock<'_> {} unsafe impl Send for StdoutLock<'_> {}
/// The state of the asynchronous stdout. /// The state of the asynchronous stdout.
@ -128,8 +122,6 @@ impl Stdout {
/// # /// #
/// # Ok(()) }) } /// # Ok(()) }) }
/// ``` /// ```
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(any(feature = "unstable", feature = "docs"))]
pub async fn lock(&self) -> StdoutLock<'static> { pub async fn lock(&self) -> StdoutLock<'static> {
static STDOUT: Lazy<std::io::Stdout> = Lazy::new(std::io::stdout); static STDOUT: Lazy<std::io::Stdout> = Lazy::new(std::io::stdout);
@ -240,8 +232,6 @@ cfg_windows! {
} }
} }
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl Write for StdoutLock<'_> { impl Write for StdoutLock<'_> {
fn poll_write( fn poll_write(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,

Loading…
Cancel
Save