Skip to content

Commit

Permalink
Rollup merge of #74192 - xkr47:patch-1, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Improve documentation on process::Child.std* fields

As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
  • Loading branch information
tmandry authored Aug 14, 2020
2 parents 3111a8c + 90e4c90 commit dae020d
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,38 @@ pub struct Child {
handle: imp::Process,

/// The handle for writing to the child's standard input (stdin), if it has
/// been captured.
/// been captured. To avoid partially moving
/// the `child` and thus blocking yourself from calling
/// functions on `child` while using `stdin`,
/// you might find it helpful:
///
/// ```compile_fail,E0425
/// let stdin = child.stdin.take().unwrap();
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub stdin: Option<ChildStdin>,

/// The handle for reading from the child's standard output (stdout), if it
/// has been captured.
/// has been captured. You might find it helpful to do
///
/// ```compile_fail,E0425
/// let stdout = child.stdout.take().unwrap();
/// ```
///
/// to avoid partially moving the `child` and thus blocking yourself from calling
/// functions on `child` while using `stdout`.
#[stable(feature = "process", since = "1.0.0")]
pub stdout: Option<ChildStdout>,

/// The handle for reading from the child's standard error (stderr), if it
/// has been captured.
/// has been captured. You might find it helpful to do
///
/// ```compile_fail,E0425
/// let stderr = child.stderr.take().unwrap();
/// ```
///
/// to avoid partially moving the `child` and thus blocking yourself from calling
/// functions on `child` while using `stderr`.
#[stable(feature = "process", since = "1.0.0")]
pub stderr: Option<ChildStderr>,
}
Expand Down

0 comments on commit dae020d

Please sign in to comment.