Skip to content

Commit 27e44ed

Browse files
committed
Add doc example for std::process::ExitStatus::success.
1 parent 3085ec7 commit 27e44ed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libstd/process.rs

+17
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,23 @@ pub struct ExitStatus(imp::ExitStatus);
605605
impl ExitStatus {
606606
/// Was termination successful? Signal termination not considered a success,
607607
/// and success is defined as a zero exit status.
608+
///
609+
/// # Examples
610+
///
611+
/// ```rust,no_run
612+
/// use std::process::Command;
613+
///
614+
/// let status = Command::new("mkdir")
615+
/// .arg("projects")
616+
/// .status()
617+
/// .expect("failed to execute mkdir");
618+
///
619+
/// if status.success() {
620+
/// println!("'projects/' directory created");
621+
/// } else {
622+
/// println!("failed to create 'projects/' directory");
623+
/// }
624+
/// ```
608625
#[stable(feature = "process", since = "1.0.0")]
609626
pub fn success(&self) -> bool {
610627
self.0.success()

0 commit comments

Comments
 (0)