Skip to content

Commit

Permalink
Rollup merge of rust-lang#66114 - golddranks:improve_thread_docs, r=C…
Browse files Browse the repository at this point in the history
…entril

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.
  • Loading branch information
JohnTitor authored Nov 7, 2019
2 parents b94a2f9 + 8568204 commit 3032233
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3032233

Please sign in to comment.