Skip to content
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

Add documentation to process::Child fields #3437

Merged
merged 3 commits into from
Jan 16, 2021
Merged
Changes from 1 commit
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
26 changes: 23 additions & 3 deletions tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,15 +839,35 @@ pub struct Child {
child: FusedChild,

/// 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 to do:
///
/// ```compile_fail,E0425
/// let stdin = child.stdin.take().unwrap();
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not have tests that fail to compile.

Suggested change
/// ```compile_fail,E0425
/// let stdin = child.stdin.take().unwrap();
/// ```
/// ```no_run
/// # let child: tokio::process::Child = unreachable!();
/// let stdin = child.stdin.take().unwrap();
/// ```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the code suggested errors because the second line in unreachable, what do prefer to do? Set it to ignore rather than no_run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just throw in some dummy command instead.

let child = tokio::process::Command::new("echo").spawn().unwrap();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.
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`.
pub stderr: Option<ChildStderr>,
}

Expand Down