D8153: rust-index: moved constructor in separate impl block
Closed by commit rHG887d0f921b34: rust-index: moved constructor in separate impl block (authored by gracinet). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8153?vs=20652=20691 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8153/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8153 AFFECTED FILES rust/hg-cpython/src/revlog.rs CHANGE DETAILS 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 @@ 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 @@ }); 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( , To: Alphare, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D8153: rust-index: moved constructor in separate impl block
Alphare updated this revision to Diff 20652. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8153?vs=20328=20652 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8153/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8153 AFFECTED FILES rust/hg-cpython/src/revlog.rs CHANGE DETAILS 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 @@ 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 @@ }); 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( , To: Alphare, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D8153: rust-index: moved constructor in separate impl block
Alphare created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY 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. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D8153 AFFECTED FILES rust/hg-cpython/src/revlog.rs CHANGE DETAILS 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 @@ 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 @@ }); 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( , To: Alphare, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel