rust/hg-core/src/revlog/index.rs
changeset 46091 9eb07ab3f2d4
parent 46037 88e741bf2d93
child 46511 43d63979a75e
--- a/rust/hg-core/src/revlog/index.rs	Mon Dec 07 18:06:53 2020 +0100
+++ b/rust/hg-core/src/revlog/index.rs	Fri Dec 04 17:27:10 2020 +0100
@@ -132,6 +132,16 @@
     }
 }
 
+impl super::RevlogIndex for Index {
+    fn len(&self) -> usize {
+        self.len()
+    }
+
+    fn node(&self, rev: Revision) -> Option<&Node> {
+        self.get_entry(rev).map(|entry| entry.hash())
+    }
+}
+
 #[derive(Debug)]
 pub struct IndexEntry<'a> {
     bytes: &'a [u8],
@@ -190,7 +200,7 @@
     ///
     /// Currently, SHA-1 is used and only the first 20 bytes of this field
     /// are used.
-    pub fn hash(&self) -> &Node {
+    pub fn hash(&self) -> &'a Node {
         (&self.bytes[32..52]).try_into().unwrap()
     }
 }