Skip to content

Commit

Permalink
Auto merge of #34313 - frewsxcv:panicking-example, r=steveklabnik
Browse files Browse the repository at this point in the history
Add example in docs for `std::thread::panicking`.

None
  • Loading branch information
bors authored Jun 19, 2016
2 parents 3313e50 + 9944b22 commit d06f1dc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,35 @@ pub fn yield_now() {
}

/// Determines whether the current thread is unwinding because of panic.
///
/// # Examples
///
/// ```rust,should_panic
/// use std::thread;
///
/// struct SomeStruct;
///
/// impl Drop for SomeStruct {
/// fn drop(&mut self) {
/// if thread::panicking() {
/// println!("dropped while unwinding");
/// } else {
/// println!("dropped while not unwinding");
/// }
/// }
/// }
///
/// {
/// print!("a: ");
/// let a = SomeStruct;
/// }
///
/// {
/// print!("b: ");
/// let b = SomeStruct;
/// panic!()
/// }
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn panicking() -> bool {
Expand Down

0 comments on commit d06f1dc

Please sign in to comment.