Rollup merge of #32431 - nicholasf:tweak/improve-expression, r=steveklabnik
Simplifying some of the phrasing explaining lifetime elision Just simplifying some of the language expressing what kind of inference Rust can and can't do on function signatures.
This commit is contained in:
commit
d7bf3d3284
1 changed files with 6 additions and 8 deletions
|
@ -282,14 +282,12 @@ to it.
|
||||||
|
|
||||||
## Lifetime Elision
|
## Lifetime Elision
|
||||||
|
|
||||||
Rust supports powerful local type inference in function bodies, but it’s
|
Rust supports powerful local type inference in the bodies of functions but not in their item signatures.
|
||||||
forbidden in item signatures to allow reasoning about the types based on
|
It's forbidden to allow reasoning about types based on the item signature alone.
|
||||||
the item signature alone. However, for ergonomic reasons a very restricted
|
However, for ergonomic reasons, a very restricted secondary inference algorithm called
|
||||||
secondary inference algorithm called “lifetime elision” applies in function
|
“lifetime elision” does apply when judging lifetimes. Lifetime elision is concerned solely to infer
|
||||||
signatures. It infers only based on the signature components themselves and not
|
lifetime parameters using three easily memorizable and unambiguous rules. This means lifetime elision
|
||||||
based on the body of the function, only infers lifetime parameters, and does
|
acts as a shorthand for writing an item signature, while not hiding
|
||||||
this with only three easily memorizable and unambiguous rules. This makes
|
|
||||||
lifetime elision a shorthand for writing an item signature, while not hiding
|
|
||||||
away the actual types involved as full local inference would if applied to it.
|
away the actual types involved as full local inference would if applied to it.
|
||||||
|
|
||||||
When talking about lifetime elision, we use the term *input lifetime* and
|
When talking about lifetime elision, we use the term *input lifetime* and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue