# HG changeset patch # User Arseniy Alekseyev # Date 2023-06-01 11:05:32 # Node ID 6a019a03708507a2379e4b64a978235863a57773 # Parent 475c170bb815ca3e9b6c8b96aa1fad04f6987844 cleanup: simplify code diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs b/rust/hg-cpython/src/dirstate/dirs_multiset.rs --- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs @@ -54,16 +54,11 @@ py_class!(pub class Dirs |py| { def addpath(&self, path: PyObject) -> PyResult { self.inner(py).borrow_mut().add_path( HgPath::new(path.extract::(py)?.data(py)), - ).and(Ok(py.None())).or_else(|e| { - match e { - e => { - Err(PyErr::new::( + ).and(Ok(py.None())).map_err(|e| PyErr::new::( py, e.to_string(), - )) - } - } - }) + ) + ) } def delpath(&self, path: PyObject) -> PyResult { @@ -71,16 +66,12 @@ py_class!(pub class Dirs |py| { HgPath::new(path.extract::(py)?.data(py)), ) .and(Ok(py.None())) - .or_else(|e| { - match e { - e => { - Err(PyErr::new::( + .map_err(|e| + PyErr::new::( py, e.to_string(), - )) - } - } - }) + ) + ) } def __iter__(&self) -> PyResult { let leaked_ref = self.inner(py).leak_immutable();