diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-11-07 09:20:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-07 09:20:42 +0900 |
| commit | 3032233bb277202a5336c2dedee999a1b3e698c3 (patch) | |
| tree | e36866d9132fb0cba5e150902e9f4f2967411316 /src/libstd/thread | |
| parent | b94a2f9e388c98f0f21d97558d0205578482422d (diff) | |
| parent | 8568204f4e934ff93817f948b13a9c804277a6bf (diff) | |
| download | rust-3032233bb277202a5336c2dedee999a1b3e698c3.tar.gz rust-3032233bb277202a5336c2dedee999a1b3e698c3.zip | |
Rollup merge of #66114 - golddranks:improve_thread_docs, r=Centril
Improve std::thread::Result documentation Thanks to @dtolnay for pointing out the different premise of the contents of the `Err` variant in `std::thread::Result` WRT normal error handling.
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 0ffa6ace2e4..0c632d2afbd 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1271,6 +1271,18 @@ impl fmt::Debug for Thread { /// /// Indicates the manner in which a thread exited. /// +/// The value contained in the `Result::Err` variant +/// is the value the thread panicked with; +/// that is, the argument the `panic!` macro was called with. +/// Unlike with normal errors, this value doesn't implement +/// the [`Error`](crate::error::Error) trait. +/// +/// Thus, a sensible way to handle a thread panic is to either: +/// 1. `unwrap` the `Result<T>`, propagating the panic +/// 2. or in case the thread is intended to be a subsystem boundary +/// that is supposed to isolate system-level failures, +/// match on the `Err` variant and handle the panic in an appropriate way. +/// /// A thread that completes without panicking is considered to exit successfully. /// /// # Examples |
