Rollup merge of #41090 - rap2hpoutre:patch-2, r=steveklabnik

Add example to std::process::abort

This is a second step in order to complete this issue: https://github.com/rust-lang/rust/issues/29370
I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: https://github.com/rust-lang/rust/issues/29370#issuecomment-290653877
This commit is contained in:
Corey Farwell 2017-04-06 14:55:05 -04:00 committed by GitHub
commit a7502761ff

View File

@ -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() };