@@ -754,6 +754,13 @@ impl fmt::Debug for Stdio {
754
754
}
755
755
756
756
/// Describes the result of a process after it has terminated.
757
+ ///
758
+ /// This `struct` is used to represent the exit status of a child process.
759
+ /// Child processes are created via the [`Command`] struct and their exit
760
+ /// status is exposed through the [`status`] method.
761
+ ///
762
+ /// [`Command`]: struct.Command.html
763
+ /// [`status`]: struct.Command.html#method.status
757
764
#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
758
765
#[ stable( feature = "process" , since = "1.0.0" ) ]
759
766
pub struct ExitStatus ( imp:: ExitStatus ) ;
@@ -788,6 +795,22 @@ impl ExitStatus {
788
795
/// On Unix, this will return `None` if the process was terminated
789
796
/// by a signal; `std::os::unix` provides an extension trait for
790
797
/// extracting the signal and other details from the `ExitStatus`.
798
+ ///
799
+ /// # Examples
800
+ ///
801
+ /// ```no_run
802
+ /// use std::process::Command;
803
+ ///
804
+ /// let status = Command::new("mkdir")
805
+ /// .arg("projects")
806
+ /// .status()
807
+ /// .expect("failed to execute mkdir");
808
+ ///
809
+ /// match status.code() {
810
+ /// Some(code) => println!("Exited with status code: {}", code),
811
+ /// None => println!("Process terminated by signal")
812
+ /// }
813
+ /// ```
791
814
#[ stable( feature = "process" , since = "1.0.0" ) ]
792
815
pub fn code ( & self ) -> Option < i32 > {
793
816
self . 0 . code ( )
0 commit comments