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