diff options
| author | bors <bors@rust-lang.org> | 2016-06-19 02:24:15 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-19 02:24:15 -0700 |
| commit | d06f1dcd7d3b9d9d5e0dc32ea7207a07e3408200 (patch) | |
| tree | c95f3169f8c961f15b985dc25ba41a7c83a3f0da /src/libstd/thread | |
| parent | 3313e50594aeb8e81dbe7bac27addcf41be40f9c (diff) | |
| parent | 9944b223a29755fe685be292c6a5c31a0ad4b59c (diff) | |
| download | rust-d06f1dcd7d3b9d9d5e0dc32ea7207a07e3408200.tar.gz rust-d06f1dcd7d3b9d9d5e0dc32ea7207a07e3408200.zip | |
Auto merge of #34313 - frewsxcv:panicking-example, r=steveklabnik
Add example in docs for `std::thread::panicking`. None
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index c8783a60c41..c474aa60b3e 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -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 { |
