changeset 50537:6a019a037085

cleanup: simplify code
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 01 Jun 2023 12:05:32 +0100
parents 475c170bb815
children a7513d0d451b
files rust/hg-cpython/src/dirstate/dirs_multiset.rs
diffstat 1 files changed, 7 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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();