Add examples in docs for JoinHandle
.
This commit is contained in:
parent
6e848be5f8
commit
5e9b75e2dd
@ -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")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user