Skip to content

Commit

Permalink
Rollup merge of rust-lang#41090 - rap2hpoutre:patch-2, r=steveklabnik
Browse files Browse the repository at this point in the history
Add example to std::process::abort

This is a second step in order to complete this issue: rust-lang#29370
I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: rust-lang#29370 (comment)
  • Loading branch information
frewsxcv authored Apr 6, 2017
2 parents 9516c80 + 16c77d7 commit a750276
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,27 @@ pub fn exit(code: i32) -> ! {
/// // execution never gets here
/// }
/// ```
///
/// The [`abort`] function terminates the process, so the destructor will not
/// get run on the example below:
///
/// ```no_run
/// use std::process;
///
/// struct HasDrop;
///
/// impl Drop for HasDrop {
/// fn drop(&mut self) {
/// println!("This will never be printed!");
/// }
/// }
///
/// fn main() {
/// let _x = HasDrop;
/// process::abort();
/// // the destructor implemented for HasDrop will never get run
/// }
/// ```
#[stable(feature = "process_abort", since = "1.17.0")]
pub fn abort() -> ! {
unsafe { ::sys::abort_internal() };
Expand Down

0 comments on commit a750276

Please sign in to comment.