Skip to content

Commit

Permalink
Auto merge of rust-lang#41768 - rap2hpoutre:patch-4, r=frewsxcv
Browse files Browse the repository at this point in the history
Add an example to std::thread::Result type

This PR is a part of rust-lang#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
  • Loading branch information
bors committed May 6, 2017
2 parents 42a4f37 + 71aaab1 commit 8aad3a3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;

Expand Down

0 comments on commit 8aad3a3

Please sign in to comment.