More clippy fixes.
This commit is contained in:
parent
039c6572c3
commit
45df367d7e
|
@ -1519,7 +1519,7 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> {
|
|||
}
|
||||
}
|
||||
|
||||
fn has_neighbor<'a>(&self, addr: &'a IpAddress, timestamp: Instant) -> bool {
|
||||
fn has_neighbor(&self, addr: &IpAddress, timestamp: Instant) -> bool {
|
||||
match self.route(addr, timestamp) {
|
||||
Ok(routed_addr) => {
|
||||
self.neighbor_cache
|
||||
|
|
|
@ -88,11 +88,11 @@ impl<'a> Parser<'a> {
|
|||
|
||||
fn accept_digit(&mut self, hex: bool) -> Result<u8> {
|
||||
let digit = self.advance()?;
|
||||
if digit >= b'0' && digit <= b'9' {
|
||||
if (b'0'..=b'9').contains(&digit) {
|
||||
Ok(digit - b'0')
|
||||
} else if hex && digit >= b'a' && digit <= b'f' {
|
||||
} else if hex && (b'a'..=b'f').contains(&digit) {
|
||||
Ok(digit - b'a' + 10)
|
||||
} else if hex && digit >= b'A' && digit <= b'F' {
|
||||
} else if hex && (b'A'..=b'F').contains(&digit) {
|
||||
Ok(digit - b'A' + 10)
|
||||
} else {
|
||||
Err(())
|
||||
|
|
|
@ -1416,7 +1416,7 @@ impl<'a> TcpSocket<'a> {
|
|||
payload_len, payload_offset);
|
||||
self.rx_buffer.write_unallocated(payload_offset, repr.payload);
|
||||
}
|
||||
Err(()) => {
|
||||
Err(_) => {
|
||||
net_debug!("{}:{}:{}: assembler: too many holes to add {} octets at offset {}",
|
||||
self.meta.handle, self.local_endpoint, self.remote_endpoint,
|
||||
payload_len, payload_offset);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
use core::fmt;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct TooManyHolesError;
|
||||
|
||||
/// A contiguous chunk of absent data, followed by a contiguous chunk of present data.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
struct Contig {
|
||||
|
@ -148,10 +151,10 @@ impl Assembler {
|
|||
}
|
||||
|
||||
/// Add a contig at the given index, and return a pointer to it.
|
||||
fn add_contig_at(&mut self, at: usize) -> Result<&mut Contig, ()> {
|
||||
fn add_contig_at(&mut self, at: usize) -> Result<&mut Contig, TooManyHolesError> {
|
||||
debug_assert!(!self.contigs[at].is_empty());
|
||||
|
||||
if !self.back().is_empty() { return Err(()) }
|
||||
if !self.back().is_empty() { return Err(TooManyHolesError) }
|
||||
|
||||
for i in (at + 1..self.contigs.len()).rev() {
|
||||
self.contigs[i] = self.contigs[i - 1];
|
||||
|
@ -163,7 +166,7 @@ impl Assembler {
|
|||
|
||||
/// Add a new contiguous range to the assembler, and return `Ok(())`,
|
||||
/// or return `Err(())` if too many discontiguities are already recorded.
|
||||
pub fn add(&mut self, mut offset: usize, mut size: usize) -> Result<(), ()> {
|
||||
pub fn add(&mut self, mut offset: usize, mut size: usize) -> Result<(), TooManyHolesError> {
|
||||
let mut index = 0;
|
||||
while index != self.contigs.len() && size != 0 {
|
||||
let contig = self.contigs[index];
|
||||
|
@ -413,7 +416,7 @@ mod test {
|
|||
}
|
||||
// Maximum of allowed holes is reached
|
||||
let assr_before = assr.clone();
|
||||
assert_eq!(assr.add(1, 3), Err(()));
|
||||
assert_eq!(assr.add(1, 3), Err(TooManyHolesError));
|
||||
assert_eq!(assr_before, assr);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ impl<'a, T: 'a> RingBuffer<'a, T> {
|
|||
/// or return `Err(Error::Exhausted)` if the buffer is full.
|
||||
///
|
||||
/// This function is a shortcut for `ring_buf.enqueue_one_with(Ok)`.
|
||||
pub fn enqueue_one<'b>(&'b mut self) -> Result<&'b mut T> {
|
||||
pub fn enqueue_one(&mut self) -> Result<&mut T> {
|
||||
self.enqueue_one_with(Ok)
|
||||
}
|
||||
|
||||
|
|
|
@ -307,14 +307,6 @@ impl<'a> Ipv6OptionsIterator<'a> {
|
|||
length, data
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to return an error in the implementation
|
||||
/// of `Iterator`.
|
||||
#[inline]
|
||||
fn return_err(&mut self, err: Error) -> Option<Result<Repr<'a>>> {
|
||||
self.hit_error = true;
|
||||
Some(Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for Ipv6OptionsIterator<'a> {
|
||||
|
@ -332,12 +324,14 @@ impl<'a> Iterator for Ipv6OptionsIterator<'a> {
|
|||
Some(Ok(repr))
|
||||
}
|
||||
Err(e) => {
|
||||
self.return_err(e)
|
||||
self.hit_error = true;
|
||||
Some(Err(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
self.return_err(e)
|
||||
self.hit_error = true;
|
||||
Some(Err(e))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue