about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorPyry Kontio <pyry.kontio@drasa.eu>2019-11-05 19:16:09 +0900
committerPyry Kontio <kontio@r.recruit.co.jp>2019-11-05 19:23:12 +0900
commit002c1c74d99295e49e30a02fb98f25383f1576f8 (patch)
tree8168354fc0ed3b12697b878d8815404becea2a08 /src/libstd/thread
parent2e4da3caadc61fab2cfcffebcbfdd72fbcee62b7 (diff)
downloadrust-002c1c74d99295e49e30a02fb98f25383f1576f8.tar.gz
rust-002c1c74d99295e49e30a02fb98f25383f1576f8.zip
Improve std::thread::Result documentation
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index 0ffa6ace2e4..2af0a4804ef 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 parameter the `panic!` macro was called with.
+/// Unlike with normal errors, this value doesn't implement
+/// the `std::error::Error` trait.
+///
+/// Thus, a sensible way to handle a thread panic is to either
+/// `unwrap` the `Result`, propagating the panic,
+/// or in case the thread is intended to be a subsystem boundary
+/// that is supposed to isolate system-level failures,
+/// match for the `Err` variant and handle the panic in an appropriate way.
+///
 /// A thread that completes without panicking is considered to exit successfully.
 ///
 /// # Examples