diff rust/hg-pyo3/src/revlog/mod.rs @ 52787:e5f89bd1a5ee

rust-pyo3-revlog: _index___len__
author Georges Racinet <georges.racinet@cloudcrane.io>
date Wed, 25 Dec 2024 17:15:35 +0100
parents 4e34e8fd46d4
children e29e75e8328c
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs	Wed Dec 25 16:16:22 2024 +0100
+++ b/rust/hg-pyo3/src/revlog/mod.rs	Wed Dec 25 17:15:35 2024 +0100
@@ -6,6 +6,7 @@
 //
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
+#![allow(non_snake_case)]
 use pyo3::buffer::PyBuffer;
 use pyo3::prelude::*;
 use pyo3::types::{PyBytes, PyBytesMethods, PyList};
@@ -223,6 +224,10 @@
                 .map(|rev| py_node_for_rev(slf.py(), idx, rev)))
         })
     }
+
+    fn _index___len__(slf: &Bound<'_, Self>) -> PyResult<usize> {
+        Self::with_index_read(slf, |idx| Ok(idx.len()))
+    }
 }
 
 impl InnerRevlog {
@@ -253,7 +258,6 @@
         f(&self_ref, guard)
     }
 
-    #[allow(dead_code)]
     fn with_index_read<T>(
         slf: &Bound<'_, Self>,
         f: impl FnOnce(&Index) -> PyResult<T>,