Skip to content

Conversation

jalil-salame
Copy link
Contributor

Previously the iterators would return references with lifetimes that were shorter than the actual lifetimes of the gix::Reference themselves. This was dues to a footgun with '_ (eliding the lifetime).

When a function returns an elided lifetime, this lifetime usually is the lifetime of the &self parameter, but sometimes it is the lifetime of the type itself (e.g. Iter<'_>).

I made the lifetimes explicit to ensure we were using the correct ones.

Closes #2103

jalil-salame and others added 2 commits August 4, 2025 23:29
Previously the iterators would return references with lifetimes that
were shorter than the actual lifetimes of the `gix::Reference`
themselves. This was dues to a footgun with `'_` (eliding the lifetime).

When a function returns an elided lifetime, this lifetime usually is the
lifetime of the `&self` parameter, but sometimes it is the lifetime of
the type itself (e.g. `Iter<'_>`).

I made the lifetimes explicit to ensure we were using the correct ones.

Closes GitoxideLabs#2103
- adjust test location
- simplify lifetimes
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for helping with this!

The lifetime-part of my refactor you may find interesting - I hope that doesn't break it (again).
If it does, let's add another test and fix it for good.

@Byron Byron enabled auto-merge August 5, 2025 02:42
@Byron Byron merged commit 04a18f3 into GitoxideLabs:main Aug 5, 2025
23 checks passed
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.

gix library returning too short of a lifetime
2 participants