Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lifetime-elision.md #1795

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Update lifetime-elision.md #1795

merged 1 commit into from
Feb 8, 2024

Conversation

IP1llar
Copy link
Contributor

@IP1llar IP1llar commented Feb 8, 2024

In the details section, it is suggested to adjust the signature of the nearest function to "lie" about the lifetimes returned to:

fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {

to demonstrate the compiler checks lifetimes for validity. However, the syntax for 'q is incorrect and it should instead be

fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {

In the details section, it is suggested to adjust the signature of the nearest function to "lie" about the lifetimes returned to:

fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {

to demonstrate the compiler checks lifetimes for validity. However, the syntax for 'q is incorrect and it should instead be

fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {
@djmitche djmitche self-requested a review February 8, 2024 19:31
Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I blame someone's "helpful" editor :)

@djmitche djmitche enabled auto-merge (squash) February 8, 2024 19:44
@djmitche djmitche merged commit d153145 into google:main Feb 8, 2024
32 checks passed
mani-chand pushed a commit to mani-chand/comprehensive-rust that referenced this pull request Feb 16, 2024
In the details section, it is suggested to adjust the signature of the
nearest function to "lie" about the lifetimes returned to:

fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q
Point> {

to demonstrate the compiler checks lifetimes for validity. However, the
syntax for 'q is incorrect and it should instead be

fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q
Point> {
@@ -61,7 +61,7 @@ references in its arguments that requires explicit annotation.
Try adjusting the signature to "lie" about the lifetimes returned:

```rust,ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could perhaps take out the ignore part here — and fill the body with a todo!()?

That should have prevented this kind of tiny typo from occurring. Alternatively, we could put the Rust code in a separate file and include just the line needed to demonstrate the point.

Just some food for thought in case @IP1llar has some free time and want to send us more PRs 😄

@mgeisler
Copy link
Collaborator

Thanks a lot @IP1llar for fixing this! We have so many pages now that we're super dependent on folks like you to help us fix typos like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants