Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs Tue Jan 28 22:27:30 2020 -0500 +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sat Oct 12 23:34:05 2019 +0900 @@ -72,7 +72,7 @@ } def addpath(&self, path: PyObject) -> PyResult<PyObject> { - self.inner_shared(py).borrow_mut()?.add_path( + self.inner_shared(py).borrow_mut().add_path( HgPath::new(path.extract::<PyBytes>(py)?.data(py)), ).and(Ok(py.None())).or_else(|e| { match e { @@ -90,7 +90,7 @@ } def delpath(&self, path: PyObject) -> PyResult<PyObject> { - self.inner_shared(py).borrow_mut()?.delete_path( + self.inner_shared(py).borrow_mut().delete_path( HgPath::new(path.extract::<PyBytes>(py)?.data(py)), ) .and(Ok(py.None()))