Mercurial > hg-stable
changeset 43179:7d6758f2d50c
rust-cpython: drop self.leak_immutable() in favor of PySharedRef wrapper
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 Sep 2019 16:59:50 +0900 |
parents | 1b2200bd06b6 |
children | b3dda04e851b |
files | rust/hg-cpython/src/dirstate/dirs_multiset.rs rust/hg-cpython/src/dirstate/dirstate_map.rs rust/hg-cpython/src/ref_sharing.rs |
diffstat | 3 files changed, 14 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sun Sep 15 16:50:48 2019 +0900 +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sun Sep 15 16:59:50 2019 +0900 @@ -92,7 +92,8 @@ }) } def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirsMultisetKeysIterator::from_inner( py, leak_handle,
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Sep 15 16:50:48 2019 +0900 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Sep 15 16:59:50 2019 +0900 @@ -319,7 +319,8 @@ } def keys(&self) -> PyResult<DirstateMapKeysIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapKeysIterator::from_inner( py, leak_handle, @@ -328,7 +329,8 @@ } def items(&self) -> PyResult<DirstateMapItemsIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapItemsIterator::from_inner( py, leak_handle, @@ -337,7 +339,8 @@ } def __iter__(&self) -> PyResult<DirstateMapKeysIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapKeysIterator::from_inner( py, leak_handle, @@ -454,7 +457,8 @@ } def copymapiter(&self) -> PyResult<CopyMapKeysIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; CopyMapKeysIterator::from_inner( py, leak_handle, @@ -463,7 +467,8 @@ } def copymapitemsiter(&self) -> PyResult<CopyMapItemsIterator> { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; CopyMapItemsIterator::from_inner( py, leak_handle,
--- a/rust/hg-cpython/src/ref_sharing.rs Sun Sep 15 16:50:48 2019 +0900 +++ b/rust/hg-cpython/src/ref_sharing.rs Sun Sep 15 16:59:50 2019 +0900 @@ -319,14 +319,6 @@ { self.$shared_accessor(py).borrow_mut() } - - // TODO: remove this function in favor of $shared_accessor(py) - unsafe fn leak_immutable<'a>( - &'a self, - py: Python<'a>, - ) -> PyResult<(PyLeakedRef, &'static $inner_struct)> { - self.$shared_accessor(py).leak_immutable() - } } }; } @@ -396,7 +388,8 @@ /// data inner: PySharedRefCell<MyStruct>; /// /// def __iter__(&self) -> PyResult<MyTypeItemsIterator> { -/// let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; +/// let (leak_handle, leaked_ref) = +/// unsafe { self.inner_shared(py).leak_immutable()? }; /// MyTypeItemsIterator::from_inner( /// py, /// leak_handle,