File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
examples/std_misc/process/pipe Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ fn main() {
1616 } ;
1717
1818 {
19- // Write a string to the stdin of `wc`
19+ // Write a string to the stdin of `wc`.
20+ // stdin has type `Option<ChildStdin>`, but since we know this instance
21+ // must have one, we can directly `unwrap` it.
2022 match process. stdin . unwrap ( ) . write_all ( PANGRAM . as_bytes ( ) ) {
2123 Err ( why) => panic ! ( "couldn't write to wc stdin: {}" ,
2224 Error :: description( & why) ) ,
@@ -28,9 +30,7 @@ fn main() {
2830 // input we just sent
2931 }
3032
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
33+ // The `stdout` field also has type `Option<ChildStdout>` so must be unwrapped.
3434 let mut s = String :: new ( ) ;
3535 match process. stdout . unwrap ( ) . read_to_string ( & mut s) {
3636 Err ( why) => panic ! ( "couldn't read wc stdout: {}" ,
You can’t perform that action at this time.
0 commit comments