Clean up a couple of if-blocks

These were flagged by `cargo clippy`:

    warning: this `else { if .. }` block can be collapsed
v0.7.x
Alex Crawford 2020-12-25 23:19:48 -08:00
parent e27f6cb564
commit fff5926210
5 changed files with 10 additions and 15 deletions

View File

@ -1,3 +1,5 @@
#![allow(clippy::collapsible_if)]
mod utils;
use std::cmp;

View File

@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(unused_mut)]
#![allow(clippy::collapsible_if)]
#[cfg(feature = "std")]
#[allow(dead_code)]

View File

@ -1192,10 +1192,8 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> {
Some(lladdr) if lladdr.is_unicast() && target_addr.is_unicast() => {
if flags.contains(NdiscNeighborFlags::OVERRIDE) {
self.neighbor_cache.fill(ip_addr, lladdr, timestamp)
} else {
if !self.neighbor_cache.lookup(&ip_addr, timestamp).found() {
self.neighbor_cache.fill(ip_addr, lladdr, timestamp)
}
} else if !self.neighbor_cache.lookup(&ip_addr, timestamp).found() {
self.neighbor_cache.fill(ip_addr, lladdr, timestamp)
}
},
_ => (),

View File

@ -271,14 +271,10 @@ impl<T: AsRef<[u8]>> Packet<T> {
/// Returns `Err(Error::Truncated)` if the buffer is too short.
pub fn check_len(&self) -> Result<()> {
let len = self.buffer.as_ref().len();
if len < field::HEADER_END {
if len < field::HEADER_END || len < self.header_len() {
Err(Error::Truncated)
} else {
if len < self.header_len() {
Err(Error::Truncated)
} else {
Ok(())
}
Ok(())
}
}

View File

@ -201,11 +201,9 @@ impl Address {
} else {
ones = false;
}
} else {
if one {
// 1 where 0 was expected
return None
}
} else if one {
// 1 where 0 was expected
return None
}
mask >>= 1;
}