Skip to content

Commit a1abae9

Browse files
committed
Merge pull request #588 from sourcefrog/patch-1
std_misc/process/pipe: Update comments to match current API.
2 parents 3f64903 + f90d942 commit a1abae9

File tree

1 file changed

+8
-6
lines changed
  • examples/std_misc/process/pipe

1 file changed

+8
-6
lines changed

examples/std_misc/process/pipe/pipe.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@ fn main() {
1616
};
1717

1818
{
19-
// Write a string to the stdin of `wc`
19+
// Write a string to the `stdin` of `wc`.
20+
//
21+
// `stdin` has type `Option<ChildStdin>`, but since we know this instance
22+
// must have one, we can directly `unwrap` it.
2023
match process.stdin.unwrap().write_all(PANGRAM.as_bytes()) {
2124
Err(why) => panic!("couldn't write to wc stdin: {}",
2225
Error::description(&why)),
2326
Ok(_) => println!("sent pangram to wc"),
2427
}
2528

26-
// `stdin` gets `drop`ed here, and the pipe is closed
29+
// `stdin` gets `drop`ed here, and the pipe is closed.
30+
//
2731
// This is very important, otherwise `wc` wouldn't start processing the
28-
// input we just sent
32+
// input we just sent.
2933
}
3034

31-
// The `stdout` field also has type `Option<PipeStream>`
32-
// the `as_mut` method will return a mutable reference to the value
33-
// wrapped in a `Some` variant
35+
// The `stdout` field also has type `Option<ChildStdout>` so must be unwrapped.
3436
let mut s = String::new();
3537
match process.stdout.unwrap().read_to_string(&mut s) {
3638
Err(why) => panic!("couldn't read wc stdout: {}",

0 commit comments

Comments
 (0)