Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Nov 25, 2024
1 parent 32ed23d commit b12b644
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/block_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl BlockWriter {
/// Insert a key that must be greater than the previously added one.
pub fn insert(&mut self, key: &[u8], val: &[u8]) {
debug_assert!(self.index_key_counter <= self.index_key_interval.get());
assert!(key.len() <= u32::max_value() as usize);
assert!(val.len() <= u32::max_value() as usize);
assert!(key.len() <= u32::MAX as usize);
assert!(val.len() <= u32::MAX as usize);

if self.index_key_counter == self.index_key_interval.get() {
self.index_offsets.push(self.buffer.len() as u64);
Expand Down
3 changes: 3 additions & 0 deletions src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn zlib_decompress<R: io::Read>(data: R, out: &mut Vec<u8>) -> io::Result<()> {
}

#[cfg(not(feature = "zlib"))]
#[allow(clippy::ptr_arg)] // it doesn't understand that I need the same signature for all function
fn zlib_decompress<R: io::Read>(_data: R, _out: &mut Vec<u8>) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "unsupported zlib decompression"))
}
Expand Down Expand Up @@ -181,6 +182,7 @@ fn zstd_decompress<R: io::Read>(data: R, out: &mut Vec<u8>) -> io::Result<()> {
}

#[cfg(not(feature = "zstd"))]
#[allow(clippy::ptr_arg)] // it doesn't understand that I need the same signature for all function
fn zstd_decompress<R: io::Read>(_data: R, _out: &mut Vec<u8>) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "unsupported zstd decompression"))
}
Expand All @@ -206,6 +208,7 @@ fn lz4_decompress<R: io::Read>(data: R, out: &mut Vec<u8>) -> io::Result<()> {
}

#[cfg(not(feature = "lz4"))]
#[allow(clippy::ptr_arg)] // it doesn't understand that I need the same signature for all function
fn lz4_decompress<R: io::Read>(_data: R, _out: &mut Vec<u8>) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "unsupported lz4 decompression"))
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
#[cfg(test)]
#[macro_use]
extern crate quickcheck;
use std::borrow::Cow;
use std::convert::Infallible;
use std::mem;

Expand Down
3 changes: 3 additions & 0 deletions src/merger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl<R, MF> MergerBuilder<R, MF> {
}

/// Add a source to merge, this function can be chained.
#[allow(clippy::should_implement_trait)] // We return interior references
pub fn add(mut self, source: ReaderCursor<R>) -> Self {
self.push(source);
self
Expand Down Expand Up @@ -138,6 +139,8 @@ where
MF: MergeFunction,
{
/// Yield the entries in key-order where values have been merged when needed.
#[allow(clippy::should_implement_trait)] // We return interior references
#[allow(clippy::type_complexity)] // Return type is not THAT complex
pub fn next(&mut self) -> crate::Result<Option<(&[u8], &[u8])>, MF::Error> {
let first_entry = match self.heap.pop() {
Some(entry) => entry,
Expand Down
2 changes: 2 additions & 0 deletions src/reader/prefix_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl<R: io::Read + io::Seek> PrefixIter<R> {
}

/// Returns the next entry that starts with the given prefix.
#[allow(clippy::should_implement_trait)] // We return interior references
pub fn next(&mut self) -> crate::Result<Option<(&[u8], &[u8])>> {
let entry = if self.move_on_first_prefix {
self.move_on_first_prefix = false;
Expand Down Expand Up @@ -49,6 +50,7 @@ impl<R: io::Read + io::Seek> RevPrefixIter<R> {
}

/// Returns the next entry that starts with the given prefix.
#[allow(clippy::should_implement_trait)] // We return interior references
pub fn next(&mut self) -> crate::Result<Option<(&[u8], &[u8])>> {
let entry = if self.move_on_last_prefix {
self.move_on_last_prefix = false;
Expand Down
2 changes: 2 additions & 0 deletions src/reader/range_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl<R: io::Read + io::Seek> RangeIter<R> {
}

/// Returns the next entry that is inside of the given range.
#[allow(clippy::should_implement_trait)] // We return interior references
pub fn next(&mut self) -> crate::Result<Option<(&[u8], &[u8])>> {
let entry = if self.move_on_start {
self.move_on_start = false;
Expand Down Expand Up @@ -75,6 +76,7 @@ impl<R: io::Read + io::Seek> RevRangeIter<R> {
}

/// Returns the next entry that is inside of the given range.
#[allow(clippy::should_implement_trait)] // We return interior references
pub fn next(&mut self) -> crate::Result<Option<(&[u8], &[u8])>> {
let entry = if self.move_on_start {
self.move_on_start = false;
Expand Down
1 change: 1 addition & 0 deletions src/reader/reader_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ impl IndexBlockCursor {
}

/// Returns the index block cursors by calling the user function to load the blocks.
#[allow(clippy::type_complexity)] // Return type is not THAT complex
fn initial_index_blocks<R, FM>(
&mut self,
mut reader: R,
Expand Down
5 changes: 3 additions & 2 deletions src/sorter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ impl Entries {
/// Inserts a new entry into the buffer, if there is not
/// enough space for it to be stored, we double the buffer size.
pub fn insert(&mut self, key: &[u8], data: &[u8]) {
assert!(key.len() <= u32::max_value() as usize);
assert!(data.len() <= u32::max_value() as usize);
assert!(key.len() <= u32::MAX as usize);
assert!(data.len() <= u32::MAX as usize);

if self.fits(key, data) {
// We store the key and data bytes one after the other at the back of the buffer.
Expand Down Expand Up @@ -653,6 +653,7 @@ where
}

/// A helper function to extract the readers and the merge function.
#[allow(clippy::type_complexity)] // Return type is not THAT complex
fn extract_reader_cursors_and_merger(
mut self,
) -> crate::Result<(Vec<ReaderCursor<CC::Chunk>>, MF), MF::Error> {
Expand Down
4 changes: 2 additions & 2 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ impl Writer<()> {
}
}

impl<W: io::Write> Writer<W> {
impl<W: io::Write> AsRef<W> for Writer<W> {
/// Gets a reference to the underlying writer.
pub fn as_ref(&self) -> &W {
fn as_ref(&self) -> &W {
self.writer.as_ref()
}
}
Expand Down

0 comments on commit b12b644

Please sign in to comment.