Skip to content

Commit 4e1147f

Browse files
authored
Add example to std::process::abort
This is a second (2/3?) step in order to complete this issue: #29370 I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: #29370 (comment)
1 parent ad5dfec commit 4e1147f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/libstd/process.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,28 @@ pub fn exit(code: i32) -> ! {
10701070
/// // execution never gets here
10711071
/// }
10721072
/// ```
1073+
///
1074+
/// The abort function terminates the process, so the destructor will not get
1075+
/// run on the example below:
1076+
///
1077+
/// ```no_run
1078+
/// use std::process;
1079+
///
1080+
/// struct HasDrop;
1081+
///
1082+
/// impl Drop for HasDrop {
1083+
/// fn drop(&mut self) {
1084+
/// println!("This will never be printed!");
1085+
/// }
1086+
/// }
1087+
///
1088+
/// fn main() {
1089+
/// let _x = HasDrop;
1090+
/// process::abort();
1091+
/// // the destructor implemented for HasDrop will never get run
1092+
/// }
1093+
/// ```
1094+
///
10731095
#[stable(feature = "process_abort", since = "1.17.0")]
10741096
pub fn abort() -> ! {
10751097
unsafe { ::sys::abort_internal() };

0 commit comments

Comments
 (0)