diff rust/hg-cpython/src/dirstate/dirs_multiset.rs @ 43173:070a38737334

rust-cpython: move py_shared_state to PySharedRefCell object The goal of this series is to encapsulate more "py_shared" thingy and reduce the size of the macro, which is hard to debug. Since py_shared_state manages the borrowing state of the object owned by PySharedRefCell, this change makes more sense. If a PyObject has more than one data to be leaked into Python world, each PySharedState should incref the parent PyObject, and keep track of the corresponding borrowing state.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 Sep 2019 23:01:51 +0900
parents 7a01778bc7b7
children 5cb8867c9e2b
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Thu Oct 10 21:37:12 2019 +0200
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Sat Sep 14 23:01:51 2019 +0900
@@ -16,10 +16,7 @@
     Python,
 };
 
-use crate::{
-    dirstate::extract_dirstate,
-    ref_sharing::{PySharedRefCell, PySharedState},
-};
+use crate::{dirstate::extract_dirstate, ref_sharing::PySharedRefCell};
 use hg::{
     utils::hg_path::{HgPath, HgPathBuf},
     DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError,
@@ -28,7 +25,6 @@
 
 py_class!(pub class Dirs |py| {
     data inner: PySharedRefCell<DirsMultiset>;
-    data py_shared_state: PySharedState;
 
     // `map` is either a `dict` or a flat iterator (usually a `set`, sometimes
     // a `list`)
@@ -65,7 +61,6 @@
         Self::create_instance(
             py,
             PySharedRefCell::new(inner),
-            PySharedState::default()
         )
     }
 
@@ -115,11 +110,7 @@
 
 impl Dirs {
     pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> {
-        Self::create_instance(
-            py,
-            PySharedRefCell::new(d),
-            PySharedState::default(),
-        )
+        Self::create_instance(py, PySharedRefCell::new(d))
     }
 
     fn translate_key(