about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-06-24 08:12:58 -0400
committerCorey Farwell <coreyf@rwell.org>2016-06-24 12:25:26 -0400
commit5e9b75e2dd440a5df2c7d90f88b2660c7581d964 (patch)
tree361f3da0bedbbd59efd9a40826d8854465ed4555 /src/libstd/thread
parent6e848be5f8071f1fe6110b3ec2bee0776126f79b (diff)
downloadrust-5e9b75e2dd440a5df2c7d90f88b2660c7581d964.tar.gz
rust-5e9b75e2dd440a5df2c7d90f88b2660c7581d964.zip
Add examples in docs for `JoinHandle`.
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index 355e0f50cef..26085c86813 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -614,6 +614,30 @@ impl<T> JoinInner<T> {
 /// This `struct` is created by the [`thread::spawn`] function and the
 /// [`thread::Builder::spawn`] method.
 ///
+/// # Examples
+///
+/// Creation from [`thread::spawn`]:
+///
+/// ```rust
+/// use std::thread;
+///
+/// let join_handle: thread::JoinHandle<_> = thread::spawn(|| {
+///     // some work here
+/// });
+/// ```
+///
+/// Creation from [`thread::Builder::spawn`]:
+///
+/// ```rust
+/// use std::thread;
+///
+/// let builder = thread::Builder::new();
+///
+/// let join_handle: thread::JoinHandle<_> = builder.spawn(|| {
+///     // some work here
+/// }).unwrap();
+/// ```
+///
 /// [`thread::spawn`]: fn.spawn.html
 /// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
 #[stable(feature = "rust1", since = "1.0.0")]