From d8e1b59f42d288676240182266cf29c7a1bc6fa4 Mon Sep 17 00:00:00 2001 From: Olle Sandberg Date: Mon, 20 Jan 2025 22:28:09 +0100 Subject: [PATCH] chore(bitar): fix lints --- bitar/src/archive_reader/http_reader.rs | 10 +++++----- bitar/src/archive_reader/io_reader.rs | 2 +- bitar/src/chunk_index.rs | 12 ++++++------ bitar/src/chunker/streaming_chunker.rs | 8 ++++---- bitar/src/rolling_hash/buzhash.rs | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bitar/src/archive_reader/http_reader.rs b/bitar/src/archive_reader/http_reader.rs index 664871c..0740050 100644 --- a/bitar/src/archive_reader/http_reader.rs +++ b/bitar/src/archive_reader/http_reader.rs @@ -78,7 +78,7 @@ struct ChunkReader<'a> { request: Option, } -impl<'a> ChunkReader<'a> +impl ChunkReader<'_> where Self: Unpin, { @@ -138,7 +138,7 @@ where } } -impl<'a> Stream for ChunkReader<'a> { +impl Stream for ChunkReader<'_> { type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { @@ -266,13 +266,13 @@ mod tests { #[test] fn one_adjacent_reads() { - let chunks = vec![ChunkOffset::new(0, 1), ChunkOffset::new(10, 1)]; + let chunks = [ChunkOffset::new(0, 1), ChunkOffset::new(10, 1)]; assert_eq!(ChunkReader::adjacent_reads(&chunks[..]), 1); } #[test] fn two_adjacent_reads() { - let chunks = vec![ + let chunks = [ ChunkOffset::new(0, 1), ChunkOffset::new(1, 3), ChunkOffset::new(10, 3), @@ -282,7 +282,7 @@ mod tests { #[test] fn multiple_adjacent_reads() { - let chunks = vec![ + let chunks = [ ChunkOffset::new(0, 1), ChunkOffset::new(1, 3), ChunkOffset::new(4, 3), diff --git a/bitar/src/archive_reader/io_reader.rs b/bitar/src/archive_reader/io_reader.rs index 904aef4..af757a6 100644 --- a/bitar/src/archive_reader/io_reader.rs +++ b/bitar/src/archive_reader/io_reader.rs @@ -138,7 +138,7 @@ where } } -impl<'a, R> Stream for IoChunkReader<'a, R> +impl Stream for IoChunkReader<'_, R> where R: AsyncRead + AsyncSeek + Unpin + Send, { diff --git a/bitar/src/chunk_index.rs b/bitar/src/chunk_index.rs index 0b08062..3e05457 100644 --- a/bitar/src/chunk_index.rs +++ b/bitar/src/chunk_index.rs @@ -41,13 +41,13 @@ struct MoveChunk<'a> { source: u64, } -impl<'a> Ord for MoveChunk<'a> { +impl Ord for MoveChunk<'_> { fn cmp(&self, other: &Self) -> Ordering { self.source.cmp(&other.source) } } -impl<'a> PartialOrd for MoveChunk<'a> { +impl PartialOrd for MoveChunk<'_> { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } @@ -106,7 +106,7 @@ struct TruncatedHashSum<'a> { truncate_len: usize, } -impl<'a> HashSumKey for TruncatedHashSum<'a> { +impl HashSumKey for TruncatedHashSum<'_> { fn sum(&self) -> &[u8] { let hash = self.hash.slice(); if hash.len() > self.truncate_len { @@ -117,15 +117,15 @@ impl<'a> HashSumKey for TruncatedHashSum<'a> { } } -impl<'a> Eq for (dyn HashSumKey + 'a) {} +impl Eq for (dyn HashSumKey + '_) {} -impl<'a> PartialEq for (dyn HashSumKey + 'a) { +impl PartialEq for (dyn HashSumKey + '_) { fn eq(&self, other: &dyn HashSumKey) -> bool { self.sum() == other.sum() } } -impl<'a> std::hash::Hash for (dyn HashSumKey + 'a) { +impl std::hash::Hash for (dyn HashSumKey + '_) { fn hash(&self, state: &mut H) { self.sum().hash(state) } diff --git a/bitar/src/chunker/streaming_chunker.rs b/bitar/src/chunker/streaming_chunker.rs index 8ff6289..152e5bc 100644 --- a/bitar/src/chunker/streaming_chunker.rs +++ b/bitar/src/chunker/streaming_chunker.rs @@ -188,7 +188,7 @@ mod tests { }; let expected_offsets = { chunker_config - .new_chunker(&mut Box::new(&source_data[..])) + .new_chunker(Box::new(&source_data[..])) .map(|result| { let (offset, _chunk) = result.unwrap(); offset @@ -231,7 +231,7 @@ mod tests { static SRC: [u8; 0] = []; assert_eq!( chunker_config - .new_chunker(&mut Box::new(&SRC[..])) + .new_chunker(Box::new(&SRC[..])) .map(|result| { let (offset, chunk) = result.unwrap(); assert_eq!(chunk.len(), 0); @@ -264,7 +264,7 @@ mod tests { static SRC: [u8; 5] = [0x1f, 0x55, 0x39, 0x5e, 0xfa]; assert_eq!( chunker_config - .new_chunker(&mut Box::new(&SRC[..])) + .new_chunker(Box::new(&SRC[..])) .map(|result| { let (offset, chunk) = result.unwrap(); assert_eq!(chunk, Chunk::from(vec![0x1f, 0x55, 0x39, 0x5e, 0xfa])); @@ -297,7 +297,7 @@ mod tests { static SRC: [u8; 5] = [0x1f, 0x55, 0x39, 0x5e, 0xfa]; assert_eq!( chunker_config - .new_chunker(&mut Box::new(&SRC[..])) + .new_chunker(Box::new(&SRC[..])) .map(|result| { let (offset, chunk) = result.unwrap(); assert_eq!(chunk, Chunk::from(vec![0x1f, 0x55, 0x39, 0x5e, 0xfa])); diff --git a/bitar/src/rolling_hash/buzhash.rs b/bitar/src/rolling_hash/buzhash.rs index 7a74676..6066c9a 100644 --- a/bitar/src/rolling_hash/buzhash.rs +++ b/bitar/src/rolling_hash/buzhash.rs @@ -134,10 +134,10 @@ mod tests { fn equal_sums_for_equal_range() { let window_size = 8; let mut h = BuzHash::new(window_size); - let data1 = vec![ + let data1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, ]; - let data2 = vec![ + let data2 = [ 1, 99, 99, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, ]; let sums1: Vec = data1