@@ -38,10 +38,10 @@ use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
3838/// let mut child = Command::new("/bin/cat")
3939/// .arg("file.txt")
4040/// .spawn()
41- /// .unwrap_or_else(|e| { panic!( "failed to execute child: {}", e) } );
41+ /// .expect( "failed to execute child" );
4242///
4343/// let ecode = child.wait()
44- /// .unwrap_or_else(|e| { panic!( "failed to wait on child: {}", e) } );
44+ /// .expect( "failed to wait on child" );
4545///
4646/// assert!(ecode.success());
4747/// ```
@@ -195,7 +195,8 @@ impl FromInner<AnonPipe> for ChildStderr {
195195/// .arg("-c")
196196/// .arg("echo hello")
197197/// .output()
198- /// .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) });
198+ /// .expect("failed to execute proces");
199+ ///
199200/// let hello = output.stdout;
200201/// ```
201202#[ stable( feature = "process" , since = "1.0.0" ) ]
@@ -305,11 +306,10 @@ impl Command {
305306 ///
306307 /// # Examples
307308 ///
308- /// ```
309+ /// ```should_panic
309310 /// use std::process::Command;
310- /// let output = Command::new("cat").arg("foo.txt").output().unwrap_or_else(|e| {
311- /// panic!("failed to execute process: {}", e)
312- /// });
311+ /// let output = Command::new("/bin/cat").arg("file.txt").output()
312+ /// .expect("failed to execute process");
313313 ///
314314 /// println!("status: {}", output.status);
315315 /// println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
@@ -328,12 +328,11 @@ impl Command {
328328 ///
329329 /// # Examples
330330 ///
331- /// ```
331+ /// ```should_panic
332332 /// use std::process::Command;
333333 ///
334- /// let status = Command::new("ls").status().unwrap_or_else(|e| {
335- /// panic!("failed to execute process: {}", e)
336- /// });
334+ /// let status = Command::new("/bin/cat").arg("file.txt").status()
335+ /// .expect("failed to execute process");
337336 ///
338337 /// println!("process exited with: {}", status);
339338 /// ```
@@ -511,13 +510,13 @@ impl Child {
511510 /// use std::process::{Command, Stdio};
512511 ///
513512 /// let mut child = Command::new("/bin/cat")
514- /// .stdout(Stdio::piped())
515513 /// .arg("file.txt")
514+ /// .stdout(Stdio::piped())
516515 /// .spawn()
517- /// .unwrap_or_else(|e| { panic!( "failed to execute child: {}", e) } );
516+ /// .expect( "failed to execute child" );
518517 ///
519518 /// let ecode = child.wait_with_output()
520- /// .unwrap_or_else(|e| { panic!( "failed to wait on child: {}", e) } );
519+ /// .expect( "failed to wait on child" );
521520 ///
522521 /// assert!(ecode.success());
523522 /// ```
0 commit comments