Merge pull request #298 from ssbr/patch-1

Document lifetime elision for fn types, Fn*, impl
pull/302/head
Manish Goregaokar 3 years ago committed by GitHub
commit 0c7e5bd142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,15 +14,17 @@ T<'a>
Lifetime positions can appear as either "input" or "output": Lifetime positions can appear as either "input" or "output":
* For `fn` definitions, input refers to the types of the formal arguments * For `fn` definitions, `fn` types, and the traits `Fn`, `FnMut`, and `FnOnce`,
in the `fn` definition, while output refers to input refers to the types of the formal arguments, while output refers to
result types. So `fn foo(s: &str) -> (&str, &str)` has elided one lifetime in result types. So `fn foo(s: &str) -> (&str, &str)` has elided one lifetime in
input position and two lifetimes in output position. input position and two lifetimes in output position. Note that the input
Note that the input positions of a `fn` method definition do not positions of a `fn` method definition do not include the lifetimes that occur
include the lifetimes that occur in the method's `impl` header in the method's `impl` header (nor lifetimes that occur in the trait header,
(nor lifetimes that occur in the trait header, for a default method). for a default method).
* In the future, it should be possible to elide `impl` headers in the same manner. * For `impl` headers, all types are input. So `impl Trait<&T> for Struct<&T>`
has elided two lifetimes in input position, while `impl Struct<&T>` has elided
one.
Elision rules are as follows: Elision rules are as follows:

Loading…
Cancel
Save