rust-lang / rust-lang/nomicon

Expand on lifetime elision in impl headers

Open
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
2.3k
Forks
325
PR merge metrics
No merged PRs in 30d

Description

On the lifetime elision page the nomicon states:

In the future, it should be possible to elide impl headers in the same manner.

According to the edition guide that future is now:

When writing impl blocks, you can now elide lifetime annotations in some situations.

However that is about as far that explanation goes in the edition book. I found the RFC that accompanied this change which stated the following:

For impl headers, input refers to the lifetimes appears in the type receiving the impl, while output refers to the trait, if any. So impl<'a> Foo<'a> has 'a in input position, while impl<'a, 'b, 'c> SomeTrait<'b, 'c> for Foo<'a, 'c> has 'a in input position, 'b in output position, and 'c in both input and output positions.

Which seems like a reasonable explanation to include in the nomicon lifetime elision page.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Nomicon lifetime elision page linked in the issue, then compare its impl-header discussion with the linked Edition Guide and RFC explanation. Update the page to explain how input and output lifetimes are determined for impl headers, and verify that the examples and wording accurately reflect the current rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.