diff rust/hg-cpython/src/dirstate/dirs_multiset.rs @ 43284:ce6dd1cee4c8

rust-cpython: put leaked reference in PyLeakedRef The next patch will make PyLeakedRef manage the lifetime of the underlying object. leak_handle.data.take() will be removed soon.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 15 Sep 2019 22:06:19 +0900
parents b3dda04e851b
children ffc1fbd7d1f5
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Thu Oct 17 20:40:12 2019 -0700
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Sun Sep 15 22:06:19 2019 +0900
@@ -92,8 +92,9 @@
             })
     }
     def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> {
-        let (leak_handle, leaked_ref) =
+        let mut leak_handle =
             unsafe { self.inner_shared(py).leak_immutable()? };
+        let leaked_ref = leak_handle.data.take().unwrap();
         DirsMultisetKeysIterator::from_inner(
             py,
             leak_handle,
@@ -125,7 +126,7 @@
 
 py_shared_iterator!(
     DirsMultisetKeysIterator,
-    PyLeakedRef,
+    PyLeakedRef<&'static DirsMultiset>,
     DirsMultisetIter<'static>,
     Dirs::translate_key,
     Option<PyBytes>