diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-08-14 14:46:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-14 14:46:41 -0700 |
| commit | dae020d49116dc684b92b0f7d7c10b29520411f2 (patch) | |
| tree | 217a7181896325cfeff6839f1ba181c8c5b1e013 | |
| parent | 3111a8c1e2c4526d3c83c994e91530b26db28b59 (diff) | |
| parent | 90e4c905d352dc5c5de71af717200c879fec88f7 (diff) | |
| download | rust-dae020d49116dc684b92b0f7d7c10b29520411f2.tar.gz rust-dae020d49116dc684b92b0f7d7c10b29520411f2.zip | |
Rollup merge of #74192 - xkr47:patch-1, r=Mark-Simulacrum
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).
| -rw-r--r-- | library/std/src/process.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 4ba1940fd0e..409a9450186 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -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>, } |
