diff options
| author | raph <rap2hpoutre@users.noreply.github.com> | 2017-04-05 20:41:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-05 20:41:43 +0200 |
| commit | 4e1147f3406bcd368c50c89242bbba6a6fec5127 (patch) | |
| tree | b3403e774eeaccece8a2f0efbda537b65b74fae3 /src/libstd | |
| parent | ad5dfecc6ae23bb7d2b8075d705011918ab4f399 (diff) | |
| download | rust-4e1147f3406bcd368c50c89242bbba6a6fec5127.tar.gz rust-4e1147f3406bcd368c50c89242bbba6a6fec5127.zip | |
Add example to std::process::abort
This is a second (2/3?) 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
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/process.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 7f1a00c707c..95e625888cc 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1070,6 +1070,28 @@ 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() }; |
