Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 42849:8db8fa1de2ef
rust-cpython: introduce restricted variant of RefCell
This should catch invalid borrow_mut() calls. Still the ref-sharing
interface is unsafe.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 01 Sep 2019 17:37:30 +0900 |
parents | 01d3ce3281cf |
children | 8f549c46bc64 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Sep 01 17:35:14 2019 +0900 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Sep 01 17:37:30 2019 +0900 @@ -21,7 +21,7 @@ use crate::{ dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, dirstate::{decapsule_make_dirstate_tuple, dirs_multiset::Dirs}, - ref_sharing::PySharedState, + ref_sharing::{PySharedRefCell, PySharedState}, }; use hg::{ DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, @@ -41,14 +41,14 @@ // All attributes also have to have a separate refcount data attribute for // leaks, with all methods that go along for reference sharing. py_class!(pub class DirstateMap |py| { - data inner: RefCell<RustDirstateMap>; + data inner: PySharedRefCell<RustDirstateMap>; data py_shared_state: PySharedState; def __new__(_cls, _root: PyObject) -> PyResult<Self> { let inner = RustDirstateMap::default(); Self::create_instance( py, - RefCell::new(inner), + PySharedRefCell::new(inner), PySharedState::default() ) }