[Doc] Add 'static and Send constraints explanations to thread::spawn#41980
[Doc] Add 'static and Send constraints explanations to thread::spawn#41980bors merged 1 commit intorust-lang:masterfrom
'static and Send constraints explanations to thread::spawn#41980Conversation
'static and Send constraints explanations to thread::spawn'static and Send constraints explanations to thread::spawn
src/libstd/thread/mod.rs
Outdated
There was a problem hiding this comment.
Thread being able to outlive the scope it has been created in (i.e. detaching) is only an explanation for why closure itself is 'static, and not its return value. The return value has the 'static bound because the return value outlives the thread it is returned from; this is true regardless of whether the thread gets detached or not.
There was a problem hiding this comment.
They are actually linked.
The value a thread returns must outlive the closure, but the fact that the thread can detach implies that the closure must be 'static, since the value must live at least as long as the closure it must then also be 'static
|
r? @rust-lang/docs |
|
Tidy errors: |
|
Damn, that is valid markdown though... |
|
@steveklabnik This looks read for review. |
|
@bors: r+ rollup thanks! |
|
📌 Commit 770bd57 has been approved by |
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of rust-lang#29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of rust-lang#29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of rust-lang#29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of rust-lang#29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn` Part of rust-lang#29378. Explains why the constraints on the closure and its return value are `'static` and `Send`. Allows to tick of `thread::spawn` from the list of things to document in the `thread` module. r? @steveklabnik
Part of #29378.
Explains why the constraints on the closure and its return value are
'staticandSend.Allows to tick of
thread::spawnfrom the list of things to document in thethreadmodule.r? @steveklabnik