-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve std::process module docs #45295
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/libstd/process.rs
Outdated
//! let mut child = Command::new("/bin/cat") | ||
//! .arg("file.txt") | ||
//! // Note that by default, the output of the command will be sent to stdout | ||
//! let child = Command::new("echo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
child
needs to be mut
.
[01:19:37] failures:
[01:19:37]
[01:19:37] ---- process.rs - process (line 21) stdout ----
[01:19:37] error[E0596]: cannot borrow immutable local variable `child` as mutable
[01:19:37] --> process.rs:12:13
[01:19:37] |
[01:19:37] 7 | let child = Command::new("echo")
[01:19:37] | ----- consider changing this to `mut child`
[01:19:37] ...
[01:19:37] 12 | let ecode = child.wait()
[01:19:37] | ^^^^^ cannot borrow mutably
[01:19:37]
[01:19:37] thread 'rustc' panicked at 'couldn't compile the test', /checkout/src/librustdoc/test.rs:283:12
[01:19:37] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:19:37]
[01:19:37]
[01:19:37] failures:
[01:19:37] process.rs - process (line 21)
[01:19:37]
[01:19:37] test result: FAILED. 877 passed; 1 failed; 10 ignored; 0 measured; 0 filtered out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but a few questions. Also travis is failing for some reason.
src/libstd/process.rs
Outdated
//! | ||
//! TODO | ||
//! | ||
//! # Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this moved down? The above is still an example 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I planned on having a brief overview of the entire module first and then show some additional examples. Maybe I should rename the "Example" section to "Additional Examples"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just figured out that I could just fold the examples into the section describing Stdio
. I'll be updating the PR soon.
src/libstd/process.rs
Outdated
//! | ||
//! # Handling I/O | ||
//! | ||
//! TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you intend on filling this out in this PR? If not, I'd remove this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I plan on adding a few demonstrations of Stdio
here. Incidentally, the TODO
is causing travis to fail.
I think I've covered almost everything. If there's something else that I should mention in the docs, let me know! |
Looks like this is back in @steveklabnik's court-- I think he's at conferences this week though :) |
Yup, sorry that it took me some time. Looks great, thanks a ton! @bors: r+ rollup |
📌 Commit 3566832 has been approved by |
Improve std::process module docs Addresses part of rust-lang#29370 I've changed the first `cat` example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description. For now, I'd like feedback on the examples. r? @steveklabnik
@bors r- The example failed to run on Windows.
|
src/libstd/process.rs
Outdated
//! Note that [`ChildStderr`] and [`ChildStdout`] implement [`Write`] and | ||
//! [`ChildStdin`] implements [`Read`]: | ||
//! | ||
//! ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows does not have /bin/cat
. Could you keep it ```no_run
or change to another program for this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added no_run
to the example involving cat
and the example involving sed
.
@bors r=steveklabnik |
📌 Commit 84ab6ae has been approved by |
Improve std::process module docs Addresses part of #29370 I've changed the first `cat` example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description. For now, I'd like feedback on the examples. r? @steveklabnik
☀️ Test successful - status-appveyor, status-travis |
Addresses part of #29370
I've changed the first
cat
example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description.For now, I'd like feedback on the examples.
r? @steveklabnik