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:
parent
c20bbb22e3
commit
2547c00e1d
|
@ -230,7 +230,7 @@ impl Flash for SimFlash {
|
||||||
/// Adds a new flash bad region. Writes to this area fail with a chance
|
/// Adds a new flash bad region. Writes to this area fail with a chance
|
||||||
/// given by `rate`.
|
/// given by `rate`.
|
||||||
fn add_bad_region(&mut self, offset: usize, len: usize, rate: f32) -> Result<()> {
|
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"));
|
bail!(ebounds("Invalid rate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl Dumper {
|
||||||
self.hex.push(' ');
|
self.hex.push(' ');
|
||||||
}
|
}
|
||||||
self.hex.push_str(&format!(" {:02x}", ch)[..]);
|
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
|
ch as char
|
||||||
} else {
|
} else {
|
||||||
'.'
|
'.'
|
||||||
|
|
Loading…
Reference in New Issue