Add doc example for std::process::ExitStatus::success
.
This commit is contained in:
parent
3085ec7848
commit
27e44edb4c
1 changed files with 17 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue