@@ -38,10 +38,10 @@ use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
38
38
/// let mut child = Command::new("/bin/cat")
39
39
/// .arg("file.txt")
40
40
/// .spawn()
41
- /// .unwrap_or_else(|e| { panic!( "failed to execute child: {}", e) } );
41
+ /// .expect( "failed to execute child" );
42
42
///
43
43
/// let ecode = child.wait()
44
- /// .unwrap_or_else(|e| { panic!( "failed to wait on child: {}", e) } );
44
+ /// .expect( "failed to wait on child" );
45
45
///
46
46
/// assert!(ecode.success());
47
47
/// ```
@@ -195,7 +195,8 @@ impl FromInner<AnonPipe> for ChildStderr {
195
195
/// .arg("-c")
196
196
/// .arg("echo hello")
197
197
/// .output()
198
- /// .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) });
198
+ /// .expect("failed to execute proces");
199
+ ///
199
200
/// let hello = output.stdout;
200
201
/// ```
201
202
#[ stable( feature = "process" , since = "1.0.0" ) ]
@@ -305,11 +306,10 @@ impl Command {
305
306
///
306
307
/// # Examples
307
308
///
308
- /// ```
309
+ /// ```should_panic
309
310
/// 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");
313
313
///
314
314
/// println!("status: {}", output.status);
315
315
/// println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
@@ -328,12 +328,11 @@ impl Command {
328
328
///
329
329
/// # Examples
330
330
///
331
- /// ```
331
+ /// ```should_panic
332
332
/// use std::process::Command;
333
333
///
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");
337
336
///
338
337
/// println!("process exited with: {}", status);
339
338
/// ```
@@ -511,13 +510,13 @@ impl Child {
511
510
/// use std::process::{Command, Stdio};
512
511
///
513
512
/// let mut child = Command::new("/bin/cat")
514
- /// .stdout(Stdio::piped())
515
513
/// .arg("file.txt")
514
+ /// .stdout(Stdio::piped())
516
515
/// .spawn()
517
- /// .unwrap_or_else(|e| { panic!( "failed to execute child: {}", e) } );
516
+ /// .expect( "failed to execute child" );
518
517
///
519
518
/// 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" );
521
520
///
522
521
/// assert!(ecode.success());
523
522
/// ```
0 commit comments