Skip to content

Commit df24f16

Browse files
committed
Fix lifetime declarations to allow ancestors().all() chaining (#364)
It's now self-contained.
1 parent a7dbed1 commit df24f16

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

git-repository/src/id.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,18 @@ pub mod ancestors {
125125
}
126126

127127
/// Return an iterator to traverse all commits in the history of the commit the parent [Id] is pointing to.
128-
pub fn all(&mut self) -> Iter<'_, 'repo> {
128+
pub fn all(&mut self) -> Iter<'repo> {
129129
let tips = std::mem::replace(&mut self.tips, Box::new(None.into_iter()));
130130
let parents = self.parents;
131131
let sorting = self.sorting;
132+
let repo = self.repo;
132133
Iter {
133-
repo: self.repo,
134+
repo,
134135
inner: Box::new(
135136
git_traverse::commit::Ancestors::new(
136137
tips,
137138
git_traverse::commit::ancestors::State::default(),
138-
move |oid, buf| self.repo.objects.find_commit_iter(oid, buf),
139+
move |oid, buf| repo.objects.find_commit_iter(oid, buf),
139140
)
140141
.sorting(sorting)
141142
.parents(parents),
@@ -145,12 +146,12 @@ pub mod ancestors {
145146
}
146147

147148
/// The iterator returned by [`Ancestors::all()`].
148-
pub struct Iter<'a, 'repo> {
149+
pub struct Iter<'repo> {
149150
repo: &'repo crate::Repository,
150-
inner: Box<dyn Iterator<Item = Result<git_hash::ObjectId, git_traverse::commit::ancestors::Error>> + 'a>,
151+
inner: Box<dyn Iterator<Item = Result<git_hash::ObjectId, git_traverse::commit::ancestors::Error>> + 'repo>,
151152
}
152153

153-
impl<'a, 'repo> Iterator for Iter<'a, 'repo> {
154+
impl<'repo> Iterator for Iter<'repo> {
154155
type Item = Result<Id<'repo>, git_traverse::commit::ancestors::Error>;
155156

156157
fn next(&mut self) -> Option<Self::Item> {

0 commit comments

Comments
 (0)