diff options
| author | William Chargin <wchargin@gmail.com> | 2019-09-08 14:03:09 -0700 |
|---|---|---|
| committer | William Chargin <wchargin@gmail.com> | 2019-09-08 14:12:56 -0700 |
| commit | 9bf577311473aa0accbf0d456cbd26b7530b200f (patch) | |
| tree | 2428be140327613392a3c29dd00d83fc888efd0e /src/libstd/process.rs | |
| parent | 2b8116dced2c6c5d02e1c4359e89dc0919d6001b (diff) | |
| download | rust-9bf577311473aa0accbf0d456cbd26b7530b200f.tar.gz rust-9bf577311473aa0accbf0d456cbd26b7530b200f.zip | |
Fix `Stdio::piped` example code and lint
Summary: Invoking `rev` does not add a trailing newline when none is present in the input (at least on my Debian). Nearby examples use `echo` rather than `rev`, which probably explains the source of the discrepancy. Also, a `mut` qualifier is unused. Test Plan: Copy the code block into <https://play.rust-lang.org> with a `fn main` wrapper, and run it. Note that it compiles and runs cleanly; prior to this commit, it would emit an `unused_mut` warning and then panic. wchargin-branch: stdio-piped-docs
Diffstat (limited to 'src/libstd/process.rs')
| -rw-r--r-- | src/libstd/process.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 000f80f99e7..cecd9a5ab56 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -935,12 +935,12 @@ impl Stdio { /// .expect("Failed to spawn child process"); /// /// { - /// let mut stdin = child.stdin.as_mut().expect("Failed to open stdin"); + /// let stdin = child.stdin.as_mut().expect("Failed to open stdin"); /// stdin.write_all("Hello, world!".as_bytes()).expect("Failed to write to stdin"); /// } /// /// let output = child.wait_with_output().expect("Failed to read stdout"); - /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n"); + /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH"); /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } |
