diff options
| author | kennytm <kennytm@gmail.com> | 2018-11-13 13:03:05 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-11-13 19:20:18 +0800 |
| commit | a8bcf612d598ff9718b4d2722d74701ae8717bdb (patch) | |
| tree | c0f7d06dca809e1be80e24732ecdbfaffb8da4cc /src/libstd/process.rs | |
| parent | e9bd1f21ecc3f50aa6b13bde3190183a0be2797f (diff) | |
| parent | 3b3b60ce6e095a62351c70e19cd922e1b2357d81 (diff) | |
| download | rust-a8bcf612d598ff9718b4d2722d74701ae8717bdb.tar.gz rust-a8bcf612d598ff9718b4d2722d74701ae8717bdb.zip | |
Rollup merge of #55754 - spastorino:fix-process-output-docs, r=alexcrichton
Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err r? @nikomatsakis
Diffstat (limited to 'src/libstd/process.rs')
| -rw-r--r-- | src/libstd/process.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a9219f75362..327ad7f64c2 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -764,14 +764,15 @@ impl Command { /// /// ```should_panic /// use std::process::Command; + /// use std::io::{self, Write}; /// let output = Command::new("/bin/cat") /// .arg("file.txt") /// .output() /// .expect("failed to execute process"); /// /// println!("status: {}", output.status); - /// println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); - /// println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + /// io::stdout().write_all(&output.stdout).unwrap(); + /// io::stderr().write_all(&output.stderr).unwrap(); /// /// assert!(output.status.success()); /// ``` @@ -951,6 +952,7 @@ impl Stdio { /// /// ```no_run /// use std::process::{Command, Stdio}; + /// use std::io::{self, Write}; /// /// let output = Command::new("rev") /// .stdin(Stdio::inherit()) @@ -958,7 +960,8 @@ impl Stdio { /// .output() /// .expect("Failed to execute command"); /// - /// println!("You piped in the reverse of: {}", String::from_utf8_lossy(&output.stdout)); + /// print!("You piped in the reverse of: "); + /// io::stdout().write_all(&output.stdout).unwrap(); /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) } |
