Skip to content

Commit 5e9b75e

Browse files
committed
Add examples in docs for JoinHandle.
1 parent 6e848be commit 5e9b75e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/libstd/thread/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,30 @@ impl<T> JoinInner<T> {
614614
/// This `struct` is created by the [`thread::spawn`] function and the
615615
/// [`thread::Builder::spawn`] method.
616616
///
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+
///
617641
/// [`thread::spawn`]: fn.spawn.html
618642
/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
619643
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)