changeset 50448:071a6c1d291e

rust-changelog: introduce ChangelogEntry parent entries accessors Straightforwards now that lifetimes are explicit in `RevlogEntry` parent accessors.
author Georges Racinet <georges.racinet@octobus.net>
date Thu, 30 Mar 2023 12:21:38 +0200
parents c101e7757ed7
children 331a3cbe1c9e
files rust/hg-core/src/revlog/changelog.rs
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/changelog.rs	Thu Mar 30 12:20:53 2023 +0200
+++ b/rust/hg-core/src/revlog/changelog.rs	Thu Mar 30 12:21:38 2023 +0200
@@ -106,6 +106,20 @@
     pub fn as_revlog_entry(&self) -> &RevlogEntry {
         &self.revlog_entry
     }
+
+    pub fn p1_entry(&self) -> Result<Option<ChangelogEntry>, RevlogError> {
+        Ok(self
+            .revlog_entry
+            .p1_entry()?
+            .map(|revlog_entry| Self { revlog_entry }))
+    }
+
+    pub fn p2_entry(&self) -> Result<Option<ChangelogEntry>, RevlogError> {
+        Ok(self
+            .revlog_entry
+            .p2_entry()?
+            .map(|revlog_entry| Self { revlog_entry }))
+    }
 }
 
 /// `Changelog` entry which knows how to interpret the `changelog` data bytes.