process: deprecate Child stdio accessors in favor of pub fields (#2014)

Fixes #2009
This commit is contained in:
Ivan Petkov
2020-01-06 10:24:40 -08:00
committed by Carl Lerche
parent d45f61c183
commit 188fc6e0d2
3 changed files with 24 additions and 15 deletions
+20 -11
View File
@@ -74,7 +74,7 @@
//! let mut child = cmd.spawn()
//! .expect("failed to spawn command");
//!
//! let stdout = child.stdout().take()
//! let stdout = child.stdout.take()
//! .expect("child did not have a handle to stdout");
//!
//! let mut reader = BufReader::new(stdout).lines();
@@ -729,9 +729,18 @@ where
#[derive(Debug)]
pub struct Child {
child: ChildDropGuard<imp::Child>,
stdin: Option<ChildStdin>,
stdout: Option<ChildStdout>,
stderr: Option<ChildStderr>,
/// The handle for writing to the child's standard input (stdin), if it has
/// been captured.
pub stdin: Option<ChildStdin>,
/// The handle for reading from the child's standard output (stdout), if it
/// has been captured.
pub stdout: Option<ChildStdout>,
/// The handle for reading from the child's standard error (stderr), if it
/// has been captured.
pub stderr: Option<ChildStderr>,
}
impl Child {
@@ -747,20 +756,20 @@ impl Child {
self.child.kill()
}
/// Returns a handle for writing to the child's stdin, if it has been
/// captured.
#[doc(hidden)]
#[deprecated(note = "please use `child.stdin` instead")]
pub fn stdin(&mut self) -> &mut Option<ChildStdin> {
&mut self.stdin
}
/// Returns a handle for reading from the child's stdout, if it has been
/// captured.
#[doc(hidden)]
#[deprecated(note = "please use `child.stdout` instead")]
pub fn stdout(&mut self) -> &mut Option<ChildStdout> {
&mut self.stdout
}
/// Returns a handle for reading from the child's stderr, if it has been
/// captured.
#[doc(hidden)]
#[deprecated(note = "please use `child.stderr` instead")]
pub fn stderr(&mut self) -> &mut Option<ChildStderr> {
&mut self.stderr
}
@@ -792,7 +801,7 @@ impl Child {
Ok(vec)
}
drop(self.stdin().take());
drop(self.stdin.take());
let stdout_fut = read_to_end(self.stdout.take());
let stderr_fut = read_to_end(self.stderr.take());