Skip to content

Commit 80b352c

Browse files
committed
Rollup merge of #34438 - frewsxcv:joinhandle, r=GuillaumeGomez
Indicate how the `JoinHandle` struct is created. None
2 parents bb12a53 + 5e9b75e commit 80b352c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/libstd/thread/mod.rs

+30
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,36 @@ impl<T> JoinInner<T> {
610610
/// Due to platform restrictions, it is not possible to `Clone` this
611611
/// handle: the ability to join a child thread is a uniquely-owned
612612
/// permission.
613+
///
614+
/// This `struct` is created by the [`thread::spawn`] function and the
615+
/// [`thread::Builder::spawn`] method.
616+
///
617+
/// # Examples
618+
///
619+
/// Creation from [`thread::spawn`]:
620+
///
621+
/// ```rust
622+
/// use std::thread;
623+
///
624+
/// let join_handle: thread::JoinHandle<_> = thread::spawn(|| {
625+
/// // some work here
626+
/// });
627+
/// ```
628+
///
629+
/// Creation from [`thread::Builder::spawn`]:
630+
///
631+
/// ```rust
632+
/// use std::thread;
633+
///
634+
/// let builder = thread::Builder::new();
635+
///
636+
/// let join_handle: thread::JoinHandle<_> = builder.spawn(|| {
637+
/// // some work here
638+
/// }).unwrap();
639+
/// ```
640+
///
641+
/// [`thread::spawn`]: fn.spawn.html
642+
/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
613643
#[stable(feature = "rust1", since = "1.0.0")]
614644
pub struct JoinHandle<T>(JoinInner<T>);
615645

0 commit comments

Comments
 (0)