Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 44973:26114bd6ec60
rust: do a clippy pass
This is the result of running `cargo clippy` on hg-core/hg-cpython and fixing
the lints that do not require too much code churn (and would warrant a separate
commit/complete refactor) and only come from our code (a lot of warnings in
hg-cpython come from `rust-cpython`).
Most of those were good lints, two of them was the linter not being smart
enough (or compiler to get up to `clippy`'s level depending on how you see it).
Maybe in the future we could have `clippy` be part of the CI.
Differential Revision: https://phab.mercurial-scm.org/D8635
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 15 Jun 2020 18:26:40 +0200 |
parents | 8cdd0b9629e3 |
children | 496537c9c1b4 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Jun 15 15:14:16 2020 -0400 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Jun 15 18:26:40 2020 +0200 @@ -179,7 +179,7 @@ "other_parent", other_parent .iter() - .map(|v| PyBytes::new(py, v.as_ref())) + .map(|v| PyBytes::new(py, v.as_bytes())) .collect::<Vec<PyBytes>>() .to_py_object(py), )?; @@ -348,7 +348,11 @@ for (key, value) in self.inner(py).borrow_mut().build_file_fold_map().iter() { - dict.set_item(py, key.as_ref().to_vec(), value.as_ref().to_vec())?; + dict.set_item( + py, + key.as_bytes().to_vec(), + value.as_bytes().to_vec(), + )?; } Ok(dict) } @@ -440,8 +444,8 @@ for (key, value) in self.inner(py).borrow().copy_map.iter() { dict.set_item( py, - PyBytes::new(py, key.as_ref()), - PyBytes::new(py, value.as_ref()), + PyBytes::new(py, key.as_bytes()), + PyBytes::new(py, value.as_bytes()), )?; } Ok(dict) @@ -450,7 +454,7 @@ def copymapgetitem(&self, key: PyObject) -> PyResult<PyBytes> { let key = key.extract::<PyBytes>(py)?; match self.inner(py).borrow().copy_map.get(HgPath::new(key.data(py))) { - Some(copy) => Ok(PyBytes::new(py, copy.as_ref())), + Some(copy) => Ok(PyBytes::new(py, copy.as_bytes())), None => Err(PyErr::new::<exc::KeyError, _>( py, String::from_utf8_lossy(key.data(py)), @@ -485,7 +489,7 @@ .get(HgPath::new(key.data(py))) { Some(copy) => Ok(Some( - PyBytes::new(py, copy.as_ref()).into_object(), + PyBytes::new(py, copy.as_bytes()).into_object(), )), None => Ok(default), } @@ -549,7 +553,7 @@ py: Python, res: (&HgPathBuf, &DirstateEntry), ) -> PyResult<Option<PyBytes>> { - Ok(Some(PyBytes::new(py, res.0.as_ref()))) + Ok(Some(PyBytes::new(py, res.0.as_bytes()))) } fn translate_key_value( py: Python, @@ -557,7 +561,7 @@ ) -> PyResult<Option<(PyBytes, PyObject)>> { let (f, entry) = res; Ok(Some(( - PyBytes::new(py, f.as_ref()), + PyBytes::new(py, f.as_bytes()), make_dirstate_tuple(py, entry)?, ))) }