From 5e9b75e2dd440a5df2c7d90f88b2660c7581d964 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 24 Jun 2016 08:12:58 -0400 Subject: Add examples in docs for `JoinHandle`. --- src/libstd/thread/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/libstd/thread') 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 JoinInner { /// 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")] -- cgit 1.4.1-3-g733a5