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
This commit is contained in:
parent
ad5dfecc6a
commit
4e1147f340
@ -1070,6 +1070,28 @@ pub fn exit(code: i32) -> ! {
|
|||||||
/// // execution never gets here
|
/// // 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")]
|
#[stable(feature = "process_abort", since = "1.17.0")]
|
||||||
pub fn abort() -> ! {
|
pub fn abort() -> ! {
|
||||||
unsafe { ::sys::abort_internal() };
|
unsafe { ::sys::abort_internal() };
|
||||||
|
Loading…
Reference in New Issue
Block a user