rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 30 Mar 2023 12:20:53 +0200
changeset 50413 c101e7757ed7
parent 50412 7ef51fff2c4f
child 50414 071a6c1d291e
rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors Without this, the lifetime of the result is equated to the lifetime of the `self` reference, preventing callers, e.g., to take a `RevlogEntry` and return its `p1_entry()`, as it looks like returning something that does not outlive the *reference to* the `RevlogEntry`.
rust/hg-core/src/revlog/mod.rs
--- a/rust/hg-core/src/revlog/mod.rs	Thu Mar 30 12:14:57 2023 +0200
+++ b/rust/hg-core/src/revlog/mod.rs	Thu Mar 30 12:20:53 2023 +0200
@@ -430,7 +430,9 @@
         self.p1 != NULL_REVISION
     }
 
-    pub fn p1_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> {
+    pub fn p1_entry(
+        &self,
+    ) -> Result<Option<RevlogEntry<'revlog>>, RevlogError> {
         if self.p1 == NULL_REVISION {
             Ok(None)
         } else {
@@ -438,7 +440,9 @@
         }
     }
 
-    pub fn p2_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> {
+    pub fn p2_entry(
+        &self,
+    ) -> Result<Option<RevlogEntry<'revlog>>, RevlogError> {
         if self.p2 == NULL_REVISION {
             Ok(None)
         } else {