History

[commitgraph] Loosen lifetime restrictions on return values.

Conor Davis committed 6 years ago

Commit 701f33c1 parent 28f94b41 file · +12 −2Browse files

Showing the changes to git-commitgraph/src/file/commit.rs (1 of 1 file). Show all

Unified · Split

git-commitgraph/src/file/commit.rs+12−2
@@ -77,7 +77,12 @@ impl<'a> Commit<'a> { · 76 unmodified lines
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
@@ -85,7 +90,12 @@ impl<'a> Commit<'a> { · 1 unmodified line
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 }