cleanup: simplify code
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Thu, 01 Jun 2023 12:05:32 +0100
changeset 50571 6a019a037085
parent 50570 475c170bb815
child 50572 a7513d0d451b
cleanup: simplify code
rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Wed May 31 19:00:11 2023 +0100
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Thu Jun 01 12:05:32 2023 +0100
@@ -54,16 +54,11 @@
     def addpath(&self, path: PyObject) -> PyResult<PyObject> {
         self.inner(py).borrow_mut().add_path(
             HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
-        ).and(Ok(py.None())).or_else(|e| {
-            match e {
-                e => {
-                    Err(PyErr::new::<exc::ValueError, _>(
+        ).and(Ok(py.None())).map_err(|e| PyErr::new::<exc::ValueError, _>(
                         py,
                         e.to_string(),
-                    ))
-                }
-            }
-        })
+                    )
+        )
     }
 
     def delpath(&self, path: PyObject) -> PyResult<PyObject> {
@@ -71,16 +66,12 @@
             HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
         )
             .and(Ok(py.None()))
-            .or_else(|e| {
-                match e {
-                    e => {
-                        Err(PyErr::new::<exc::ValueError, _>(
+            .map_err(|e|
+                        PyErr::new::<exc::ValueError, _>(
                             py,
                             e.to_string(),
-                        ))
-                    }
-                }
-            })
+                        )
+            )
     }
     def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> {
         let leaked_ref = self.inner(py).leak_immutable();