# HG changeset patch # User Georges Racinet # Date 2020-01-13 18:56:16 # Node ID 887d0f921b34f2731183949a884768f75b7cb144 # Parent 1663495103986977c699ca3e279679666318da2d 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 diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -28,8 +28,7 @@ py_class!(pub class MixedIndex |py| { data cindex: RefCell; def __new__(_cls, cindex: PyObject) -> PyResult { - 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 @@ py_class!(pub class MixedIndex |py| { }); impl MixedIndex { + fn new(py: Python, cindex: PyObject) -> PyResult { + Self::create_instance( + py, + RefCell::new(cindex::Index::new(py, cindex)?), + ) + } + /// forward a method call to the underlying C index fn call_cindex( &self,