Skip to content

Commit d05a9c5

Browse files
Rollup merge of rust-lang#34438 - frewsxcv:joinhandle, r=GuillaumeGomez
Indicate how the `JoinHandle` struct is created. None
2 parents 0ee27da + 5e9b75e commit d05a9c5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/libstd/thread/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,36 @@ impl<T> JoinInner<T> {
623623
/// Due to platform restrictions, it is not possible to `Clone` this
624624
/// handle: the ability to join a child thread is a uniquely-owned
625625
/// permission.
626+
///
627+
/// This `struct` is created by the [`thread::spawn`] function and the
628+
/// [`thread::Builder::spawn`] method.
629+
///
630+
/// # Examples
631+
///
632+
/// Creation from [`thread::spawn`]:
633+
///
634+
/// ```rust
635+
/// use std::thread;
636+
///
637+
/// let join_handle: thread::JoinHandle<_> = thread::spawn(|| {
638+
/// // some work here
639+
/// });
640+
/// ```
641+
///
642+
/// Creation from [`thread::Builder::spawn`]:
643+
///
644+
/// ```rust
645+
/// use std::thread;
646+
///
647+
/// let builder = thread::Builder::new();
648+
///
649+
/// let join_handle: thread::JoinHandle<_> = builder.spawn(|| {
650+
/// // some work here
651+
/// }).unwrap();
652+
/// ```
653+
///
654+
/// [`thread::spawn`]: fn.spawn.html
655+
/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
626656
#[stable(feature = "rust1", since = "1.0.0")]
627657
pub struct JoinHandle<T>(JoinInner<T>);
628658

0 commit comments

Comments
 (0)