From 68bb5414624d80bec29883c324eb239be73e749d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Huchet?= Date: Fri, 5 May 2017 12:02:02 +0200 Subject: [PATCH 1/2] Add an example to std::thread::Result type --- src/libstd/thread/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 8e7eaa77cd709..2ce5a7262d971 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -863,9 +863,31 @@ impl fmt::Debug for Thread { // JoinHandle //////////////////////////////////////////////////////////////////////////////// +/// A specialized [`Result`] type for threads. +/// /// Indicates the manner in which a thread exited. /// /// A thread that completes without panicking is considered to exit successfully. +/// +/// # Examples +/// +/// ```no_run +/// use std::thread; +/// use std::fs; +/// +/// fn copy_in_thread() -> thread::Result<()> { +/// thread::spawn(move || { fs::copy("foo.txt", "bar.txt").unwrap(); }).join() +/// } +/// +/// fn main() { +/// match copy_in_thread() { +/// Ok(_) => println!("this is fine"), +/// Err(_) => println!("thread panicked"), +/// } +/// } +/// ``` +/// +/// [`Result`]: ../../std/result/enum.Result.html #[stable(feature = "rust1", since = "1.0.0")] pub type Result = ::result::Result>; From 71aaab1c360f9910238258fb4025b3bd5d5c0645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Huchet?= Date: Fri, 5 May 2017 12:07:14 +0200 Subject: [PATCH 2/2] Update mod.rs --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 2ce5a7262d971..279fe0376d29d 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -864,7 +864,7 @@ impl fmt::Debug for Thread { //////////////////////////////////////////////////////////////////////////////// /// A specialized [`Result`] type for threads. -/// +/// /// Indicates the manner in which a thread exited. /// /// A thread that completes without panicking is considered to exit successfully.