Mercurial > hg
comparison rust/hg-core/src/utils.rs @ 49930:e98fd81bb151
rust-clippy: fix most warnings in `hg-core`
All of these are simple changes that for the most part are clear improvements
and the rest are at most equivalent.
The remaining warnings have to be fixed either with a bigger refactor like for
the nested "revlog" module, or in the dependency `bytes-cast`, which we own.
This will be done sometime in the future.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 09 Jan 2023 19:18:43 +0100 |
parents | 5f1cd6839c69 |
children | 83437ad8fe3d |
comparison
equal
deleted
inserted
replaced
49929:5f1cd6839c69 | 49930:e98fd81bb151 |
---|---|
135 let b = iter.next()?; | 135 let b = iter.next()?; |
136 Some((a, b)) | 136 Some((a, b)) |
137 } | 137 } |
138 | 138 |
139 fn split_2_by_slice(&self, separator: &[u8]) -> Option<(&[u8], &[u8])> { | 139 fn split_2_by_slice(&self, separator: &[u8]) -> Option<(&[u8], &[u8])> { |
140 if let Some(pos) = find_slice_in_slice(self, separator) { | 140 find_slice_in_slice(self, separator) |
141 Some((&self[..pos], &self[pos + separator.len()..])) | 141 .map(|pos| (&self[..pos], &self[pos + separator.len()..])) |
142 } else { | |
143 None | |
144 } | |
145 } | 142 } |
146 } | 143 } |
147 | 144 |
148 pub trait Escaped { | 145 pub trait Escaped { |
149 /// Return bytes escaped for display to the user | 146 /// Return bytes escaped for display to the user |
367 Some(left_value) => match merge(&key, left_value, &right_value) { | 364 Some(left_value) => match merge(&key, left_value, &right_value) { |
368 MergeResult::LeftValue => {} | 365 MergeResult::LeftValue => {} |
369 MergeResult::RightValue => { | 366 MergeResult::RightValue => { |
370 left.insert(key, right_value); | 367 left.insert(key, right_value); |
371 } | 368 } |
372 MergeResult::UseNewValue(new_value) => { | 369 MergeResult::NewValue(new_value) => { |
373 left.insert(key, new_value); | 370 left.insert(key, new_value); |
374 } | 371 } |
375 }, | 372 }, |
376 } | 373 } |
377 } | 374 } |