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

Move lifetime of take_iter from iterator to its items #6403

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Move lifetime of take_iter from iterator to its items #6403

merged 1 commit into from
Sep 17, 2024

Conversation

dariocurr
Copy link
Contributor

Which issue does this PR close?

No issue, just small improvements.

Rationale for this change

Running cargo miri I saw some warnings regarding those lifetimes

42 |     pub fn take_iter<'a>(
   |                      -- lifetime `'a` declared here
...
45 |     ) -> impl Iterator<Item = Option<&str>> + 'a {
   |                                      ^ this elided lifetime gets resolved as `'a`

More in detail:

  • impl Iterator<Item = Option<&[T>> + 'a ties the lifetime 'a to the iterator itself, but not necessarily to the items it yields
  • impl Iterator<Item = Option<&'a T>> ties the lifetime 'a to the items yielded by the iterator

The latter is preferred

What changes are included in this PR?

Lifetimes moved from the iterator to the items it yields

Are there any user-facing changes?

No

@github-actions github-actions bot added the arrow Changes to the arrow crate label Sep 16, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @dariocurr - this makes sense to me

@alamb alamb changed the title Move lifetime from iterator to its items Move lifetime of take_iter from iterator to its items Sep 17, 2024
@crepererum crepererum merged commit 5414f1d into apache:master Sep 17, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants