diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-04-06 14:55:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-06 14:55:05 -0400 |
| commit | a7502761ff251748c146cbd7680b02a6337b11f6 (patch) | |
| tree | 4a8bf9e70ee2ca5a72c4c3b32269dd2fdc3f83b5 | |
| parent | 9516c80bb71824a619a539c6c8646891f7bc004a (diff) | |
| parent | 16c77d7da1d1707a90d94d9eb77e0752f974a0db (diff) | |
| download | rust-a7502761ff251748c146cbd7680b02a6337b11f6.tar.gz rust-a7502761ff251748c146cbd7680b02a6337b11f6.zip | |
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
| -rw-r--r-- | src/libstd/process.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 7f1a00c707c..8cfd8fcd8c6 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -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() }; |
