comparison rust/hg-cpython/src/dirstate/dirs_multiset.rs @ 44203:2a24ead003f0

rust-cpython: add panicking version of borrow_mut() and use it The original borrow_mut() is renamed to try_borrow_mut(). Since leak_immutable() no longer incref the borrow count, the caller should know if the underlying value is borrowed or not. No Python world is involved. That's why we can simply use the panicking borrow_mut().
author Yuya Nishihara <yuya@tcha.org>
date Sat, 12 Oct 2019 23:34:05 +0900
parents bc7d8f45c3b6
children 281642cd1d04
comparison
equal deleted inserted replaced
44202:a7f8160cc4e4 44203:2a24ead003f0
70 PySharedRefCell::new(inner), 70 PySharedRefCell::new(inner),
71 ) 71 )
72 } 72 }
73 73
74 def addpath(&self, path: PyObject) -> PyResult<PyObject> { 74 def addpath(&self, path: PyObject) -> PyResult<PyObject> {
75 self.inner_shared(py).borrow_mut()?.add_path( 75 self.inner_shared(py).borrow_mut().add_path(
76 HgPath::new(path.extract::<PyBytes>(py)?.data(py)), 76 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
77 ).and(Ok(py.None())).or_else(|e| { 77 ).and(Ok(py.None())).or_else(|e| {
78 match e { 78 match e {
79 DirstateMapError::EmptyPath => { 79 DirstateMapError::EmptyPath => {
80 Ok(py.None()) 80 Ok(py.None())
88 } 88 }
89 }) 89 })
90 } 90 }
91 91
92 def delpath(&self, path: PyObject) -> PyResult<PyObject> { 92 def delpath(&self, path: PyObject) -> PyResult<PyObject> {
93 self.inner_shared(py).borrow_mut()?.delete_path( 93 self.inner_shared(py).borrow_mut().delete_path(
94 HgPath::new(path.extract::<PyBytes>(py)?.data(py)), 94 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
95 ) 95 )
96 .and(Ok(py.None())) 96 .and(Ok(py.None()))
97 .or_else(|e| { 97 .or_else(|e| {
98 match e { 98 match e {