comparison rust/hg-cpython/src/utils.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 d738b7a18438
children c7fb9b74e753
comparison
equal deleted inserted replaced
44962:ef8dcee272ac 44973:26114bd6ec60
30 node_from_py_bytes(py, as_py_bytes) 30 node_from_py_bytes(py, as_py_bytes)
31 } 31 }
32 32
33 /// Clone incoming Python bytes given as `PyBytes` as a `Node`, 33 /// Clone incoming Python bytes given as `PyBytes` as a `Node`,
34 /// doing the necessary checks. 34 /// doing the necessary checks.
35 pub fn node_from_py_bytes<'a>( 35 pub fn node_from_py_bytes(py: Python, bytes: &PyBytes) -> PyResult<Node> {
36 py: Python,
37 bytes: &'a PyBytes,
38 ) -> PyResult<Node> {
39 <NodeData>::try_from(bytes.data(py)) 36 <NodeData>::try_from(bytes.data(py))
40 .map_err(|_| { 37 .map_err(|_| {
41 PyErr::new::<ValueError, _>( 38 PyErr::new::<ValueError, _>(
42 py, 39 py,
43 format!("{}-byte hash required", NODE_BYTES_LENGTH), 40 format!("{}-byte hash required", NODE_BYTES_LENGTH),
44 ) 41 )
45 }) 42 })
46 .map(|n| n.into()) 43 .map(Into::into)
47 } 44 }