changeset 44503:887d0f921b34

rust-index: moved constructor in separate impl block with the upcoming addition of the nodemap logic, it's going to become more complicated. Being in the separate impl block has the advantage to be subject to rustfmt, whereas code inside macro calls isn't. Differential Revision: https://phab.mercurial-scm.org/D8153
author Georges Racinet <georges.racinet@octobus.net>
date Mon, 13 Jan 2020 19:56:16 +0100
parents 166349510398
children cefd130c98be
files rust/hg-cpython/src/revlog.rs
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs	Mon Jan 13 19:31:33 2020 +0100
+++ b/rust/hg-cpython/src/revlog.rs	Mon Jan 13 19:56:16 2020 +0100
@@ -28,8 +28,7 @@
     data cindex: RefCell<cindex::Index>;
 
     def __new__(_cls, cindex: PyObject) -> PyResult<MixedIndex> {
-        Self::create_instance(py, RefCell::new(
-            cindex::Index::new(py, cindex)?))
+        Self::new(py, cindex)
     }
 
     /// Compatibility layer used for Python consumers needing access to the C index
@@ -199,6 +198,13 @@
 });
 
 impl MixedIndex {
+    fn new(py: Python, cindex: PyObject) -> PyResult<MixedIndex> {
+        Self::create_instance(
+            py,
+            RefCell::new(cindex::Index::new(py, cindex)?),
+        )
+    }
+
     /// forward a method call to the underlying C index
     fn call_cindex(
         &self,