Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/utils.rs @ 44998: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 | aa0fc32ece9e |
children | 9eb07ab3f2d4 |
line wrap: on
line diff
--- a/rust/hg-core/src/utils.rs Mon Jun 15 15:14:16 2020 -0400 +++ b/rust/hg-core/src/utils.rs Mon Jun 15 18:26:40 2020 +0200 @@ -68,6 +68,7 @@ fn drop_prefix(&self, needle: &Self) -> Option<&Self>; } +#[allow(clippy::trivially_copy_pass_by_ref)] fn is_not_whitespace(c: &u8) -> bool { !(*c as char).is_whitespace() } @@ -75,7 +76,7 @@ impl SliceExt for [u8] { fn trim_end(&self) -> &[u8] { if let Some(last) = self.iter().rposition(is_not_whitespace) { - &self[..last + 1] + &self[..=last] } else { &[] } @@ -151,7 +152,7 @@ impl<'a, T: Escaped> Escaped for &'a [T] { fn escaped_bytes(&self) -> Vec<u8> { - self.iter().flat_map(|item| item.escaped_bytes()).collect() + self.iter().flat_map(Escaped::escaped_bytes).collect() } }