Rollup merge of #34794 - frewsxcv:exitstatus-success, r=GuillaumeGomez

Add doc example for `std::process::ExitStatus::success`.

None
This commit is contained in:
Guillaume Gomez 2016-07-15 10:56:43 +02:00 committed by GitHub
commit 367f942ce4

View File

@ -605,6 +605,23 @@ pub struct ExitStatus(imp::ExitStatus);
impl ExitStatus {
/// Was termination successful? Signal termination not considered a success,
/// and success is defined as a zero exit status.
///
/// # Examples
///
/// ```rust,no_run
/// use std::process::Command;
///
/// let status = Command::new("mkdir")
/// .arg("projects")
/// .status()
/// .expect("failed to execute mkdir");
///
/// if status.success() {
/// println!("'projects/' directory created");
/// } else {
/// println!("failed to create 'projects/' directory");
/// }
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn success(&self) -> bool {
self.0.success()