File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1725,6 +1725,26 @@ impl ExitCode {
1725
1725
/// return the same codes (but will also `eprintln!` the error).
1726
1726
#[ stable( feature = "process_exitcode" , since = "1.60.0" ) ]
1727
1727
pub const FAILURE : ExitCode = ExitCode ( imp:: ExitCode :: FAILURE ) ;
1728
+
1729
+ /// Exit the current process with the given `ExitCode`.
1730
+ ///
1731
+ /// Note that this has the same caveats as [`process::exit()`][exit], namely that this function
1732
+ /// terminates the process immediately, so no destructors on the current stack or any other
1733
+ /// thread's stack will be run. If a clean shutdown is needed, it is recommended to simply
1734
+ /// return this ExitCode from the `main` function, as demonstrated in the [type
1735
+ /// documentation](#examples).
1736
+ ///
1737
+ /// # Differences from `process::exit()`
1738
+ ///
1739
+ /// `process::exit()` accepts any `i32` value as the exit code for the process; however, there
1740
+ /// are platforms that only use a subset of that value (see [`process::exit` platform-specific
1741
+ /// behavior][exit#platform-specific-behavior]). `ExitCode` exists because of this; only
1742
+ /// `ExitCode`s that are valid on all platforms can be created, so those problems don't exist
1743
+ /// with this method.
1744
+ #[ unstable( feature = "exitcode_exit_method" , issue = "none" ) ]
1745
+ pub fn exit_process ( self ) -> ! {
1746
+ exit ( self . to_i32 ( ) )
1747
+ }
1728
1748
}
1729
1749
1730
1750
impl ExitCode {
You can’t perform that action at this time.
0 commit comments