Skip to content

Commit 701f33c

Browse files
committed
[commitgraph] Loosen lifetime restrictions on return values.
1 parent 28f94b4 commit 701f33c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

git-commitgraph/src/file/commit.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,25 @@ impl<'a> Commit<'a> {
7777
}
7878
}
7979

80-
pub fn id(&self) -> borrowed::Id<'_> {
80+
// Allow the return value to outlive this Commit object, as it only needs to be bound by the
81+
// lifetime of the parent file.
82+
pub fn id<'b>(&'b self) -> borrowed::Id<'a>
83+
where
84+
'a: 'b,
85+
{
8186
self.file.id_at(self.pos)
8287
}
8388

8489
pub fn parent1(&self) -> Result<Option<graph::Position>, Error> {
8590
self.iter_parents().next().transpose()
8691
}
8792

88-
pub fn root_tree_id(&self) -> borrowed::Id<'_> {
93+
// Allow the return value to outlive this Commit object, as it only needs to be bound by the
94+
// lifetime of the parent file.
95+
pub fn root_tree_id<'b>(&'b self) -> borrowed::Id<'a>
96+
where
97+
'a: 'b,
98+
{
8999
self.root_tree_id
90100
}
91101
}

0 commit comments

Comments
 (0)