Skip to content

mark stdio-lock structs as unstable #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ pub use read::Read;
pub use repeat::{repeat, Repeat};
pub use seek::Seek;
pub use sink::{sink, Sink};
pub use stderr::{stderr, Stderr, StderrLock};
pub use stdin::{stdin, Stdin, StdinLock};
pub use stdout::{stdout, Stdout, StdoutLock};
pub use stderr::{stderr, Stderr};
pub use stdin::{stdin, Stdin};
pub use stdout::{stdout, Stdout};
pub use timeout::timeout;
pub use write::Write;

Expand All @@ -311,3 +311,9 @@ mod stdin;
mod stdio;
mod stdout;
mod timeout;

cfg_unstable! {
pub use stderr::StderrLock;
pub use stdin::StdinLock;
pub use stdout::StdoutLock;
}
14 changes: 11 additions & 3 deletions src/io/stderr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::io::Write as StdWrite;
use std::pin::Pin;
use std::sync::Mutex;

Expand All @@ -8,6 +7,7 @@ use crate::task::{spawn_blocking, Context, JoinHandle, Poll};

cfg_unstable! {
use once_cell::sync::Lazy;
use std::io::Write as _;
}

/// Constructs a new handle to the standard error of the current process.
Expand Down Expand Up @@ -59,13 +59,19 @@ pub fn stderr() -> Stderr {
pub struct Stderr(Mutex<State>);

/// A locked reference to the Stderr handle.
/// This handle implements the [`Write`] traits, and is constructed via the [`Stderr::lock`] method.
///
/// This handle implements the [`Write`] traits, and is constructed via the [`Stderr::lock`]
/// method.
///
/// [`Write`]: trait.Read.html
/// [`Stderr::lock`]: struct.Stderr.html#method.lock
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)]
pub struct StderrLock<'a>(std::io::StderrLock<'a>);

#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StderrLock<'_> {}

/// The state of the asynchronous stderr.
Expand Down Expand Up @@ -234,7 +240,9 @@ cfg_windows! {
}
}

impl Write for StderrLock<'_> {
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl io::Write for StderrLock<'_> {
fn poll_write(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
Expand Down
10 changes: 8 additions & 2 deletions src/io/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::task::{spawn_blocking, Context, JoinHandle, Poll};

cfg_unstable! {
use once_cell::sync::Lazy;
use std::io::Read as _;
}

/// Constructs a new handle to the standard input of the current process.
Expand Down Expand Up @@ -59,13 +60,18 @@ pub fn stdin() -> Stdin {
pub struct Stdin(Mutex<State>);

/// A locked reference to the Stdin handle.
///
/// This handle implements the [`Read`] traits, and is constructed via the [`Stdin::lock`] method.
///
/// [`Read`]: trait.Read.html
/// [`Stdin::lock`]: struct.Stdin.html#method.lock
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(feature = "unstable")]
#[derive(Debug)]
pub struct StdinLock<'a>(std::io::StdinLock<'a>);

#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StdinLock<'_> {}

/// The state of the asynchronous stdin.
Expand Down Expand Up @@ -257,14 +263,14 @@ cfg_windows! {
}
}

#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl Read for StdinLock<'_> {
fn poll_read(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
use std::io::Read as StdRead;

Poll::Ready(self.0.read(buf))
}
}
12 changes: 10 additions & 2 deletions src/io/stdout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::io::Write as StdWrite;
use std::pin::Pin;
use std::sync::Mutex;

Expand All @@ -8,6 +7,7 @@ use crate::task::{spawn_blocking, Context, JoinHandle, Poll};

cfg_unstable! {
use once_cell::sync::Lazy;
use std::io::Write as _;
}

/// Constructs a new handle to the standard output of the current process.
Expand Down Expand Up @@ -59,13 +59,19 @@ pub fn stdout() -> Stdout {
pub struct Stdout(Mutex<State>);

/// A locked reference to the Stderr handle.
/// This handle implements the [`Write`] traits, and is constructed via the [`Stdout::lock`] method.
///
/// This handle implements the [`Write`] traits, and is constructed via the [`Stdout::lock`]
/// method.
///
/// [`Write`]: trait.Read.html
/// [`Stdout::lock`]: struct.Stdout.html#method.lock
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)]
pub struct StdoutLock<'a>(std::io::StdoutLock<'a>);

#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
unsafe impl Send for StdoutLock<'_> {}

/// The state of the asynchronous stdout.
Expand Down Expand Up @@ -234,6 +240,8 @@ cfg_windows! {
}
}

#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
impl Write for StdoutLock<'_> {
fn poll_write(
mut self: Pin<&mut Self>,
Expand Down