sim: Use range `contains` when possible

Clippy suggests using a range with `contains` in situations where we
test if a value is within a range.

Signed-off-by: David Brown <david.brown@linaro.org>
This commit is contained in:
David Brown 2021-03-10 05:20:17 -07:00 committed by David Brown
parent c20bbb22e3
commit 2547c00e1d
2 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ impl Flash for SimFlash {
/// Adds a new flash bad region. Writes to this area fail with a chance
/// given by `rate`.
fn add_bad_region(&mut self, offset: usize, len: usize, rate: f32) -> Result<()> {
if rate < 0.0 || rate > 1.0 {
if !(0.0..=1.0).contains(&rate) {
bail!(ebounds("Invalid rate"));
}

View File

@ -34,7 +34,7 @@ impl Dumper {
self.hex.push(' ');
}
self.hex.push_str(&format!(" {:02x}", ch)[..]);
self.ascii.push(if ch >= ' ' as u8 && ch <= '~' as u8 {
self.ascii.push(if (b' '..=b'~').contains(&ch) {
ch as char
} else {
'.'