diff options
| author | bors <bors@rust-lang.org> | 2017-05-06 02:01:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-05-06 02:01:00 +0000 |
| commit | 8aad3a3524fd04db3e6ddf59604d33c8e3797108 (patch) | |
| tree | 0e2747157212d726255dd41a4a9bd3e1c48faff7 /src/libstd | |
| parent | 42a4f373c9bcb819b4485c97ef0df4b7d7fe98c5 (diff) | |
| parent | 71aaab1c360f9910238258fb4025b3bd5d5c0645 (diff) | |
| download | rust-8aad3a3524fd04db3e6ddf59604d33c8e3797108.tar.gz rust-8aad3a3524fd04db3e6ddf59604d33c8e3797108.zip | |
Auto merge of #41768 - rap2hpoutre:patch-4, r=frewsxcv
Add an example to std::thread::Result type This PR is a part of https://github.com/rust-lang/rust/issues/29378. I submit this PR with the help (mentoring) of @steveklabnik. I'm still not sure my request is good enough but I don't want to spoil the issue with too much questions so I continue here. r? @steveklabnik
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/thread/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 9cded2ab289..4cbcfdbc2d7 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -865,9 +865,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<T> = ::result::Result<T, Box<Any + Send + 'static>>; |
