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

Clarify struct-lifetimes slide #2585

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

djmitche
Copy link
Collaborator

In teaching the course, the verbal distinction between "doc" and "dog" was not clear, so this PR moves away from those symbols.

This also makes the Highlight struct a little more substantial, and replaces erase with a simple call to drop to keep the example short.

In teaching the course, the verbal distinction between "doc" and "dog"
was not clear, so this PR moves away from those symbols.

This also makes the Highlight struct a little more substantial, and
replaces `erase` with a simple call to `drop` to keep the example short.
@djmitche djmitche requested a review from hurryabit January 22, 2025 12:12
@djmitche djmitche enabled auto-merge (squash) January 22, 2025 12:12
@fw-immunant
Copy link
Collaborator

I would suggest document rather than text as the lifetime name just to demonstrate that it does not need to match the variable, and to keep the intuition that the lifetime refers to the entire source string rather than just the portion within the slice. But this is really a bikeshed.

Copy link
Collaborator

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

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

I like this. Thank you!

@djmitche djmitche merged commit 15e4637 into google:main Jan 23, 2025
35 checks passed
djmitche added a commit that referenced this pull request Jan 23, 2025
This helps clarify that the lifetime and variables names do not need to
match, but sticks to related themes (doc / document) for human clarity.

As suggested by @fw-immunant in
#2585 (review),
which subsequently auto-merged.
michael-kerscher pushed a commit to michael-kerscher/comprehensive-rust that referenced this pull request Feb 7, 2025
In teaching the course, the verbal distinction between "doc" and "dog"
was not clear, so this PR moves away from those symbols.

This also makes the Highlight struct a little more substantial, and
replaces `erase` with a simple call to `drop` to keep the example short.
michael-kerscher pushed a commit to michael-kerscher/comprehensive-rust that referenced this pull request Feb 7, 2025
This helps clarify that the lifetime and variables names do not need to
match, but sticks to related themes (doc / document) for human clarity.

As suggested by @fw-immunant in
google#2585 (review),
which subsequently auto-merged.
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