Skip to content

Commit 9bf5773

Browse files
committed
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
1 parent 2b8116d commit 9bf5773

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,12 @@ impl Stdio {
935935
/// .expect("Failed to spawn child process");
936936
///
937937
/// {
938-
/// let mut stdin = child.stdin.as_mut().expect("Failed to open stdin");
938+
/// let stdin = child.stdin.as_mut().expect("Failed to open stdin");
939939
/// stdin.write_all("Hello, world!".as_bytes()).expect("Failed to write to stdin");
940940
/// }
941941
///
942942
/// let output = child.wait_with_output().expect("Failed to read stdout");
943-
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n");
943+
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH");
944944
/// ```
945945
#[stable(feature = "process", since = "1.0.0")]
946946
pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) }

0 commit comments

Comments
 (0)