diff --git a/Cargo.toml b/Cargo.toml index 9175594..ed5c0c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ missing_docs = "warn" [lints.clippy] cargo = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } +use_self = "warn" cast_possible_truncation = "allow" cast_possible_wrap = "allow" cast_sign_loss = "allow" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index cec0a38..69e9628 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -22,6 +22,7 @@ unused_qualifications = "warn" [lints.clippy] cargo = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } +use_self = "warn" # Allow certain lints that are common in fuzz targets and not worth fixing. doc_markdown = "allow" wildcard_imports = "allow" diff --git a/src/rust/integer_compression/fastpfor.rs b/src/rust/integer_compression/fastpfor.rs index c8ef8af..fa6f6bc 100644 --- a/src/rust/integer_compression/fastpfor.rs +++ b/src/rust/integer_compression/fastpfor.rs @@ -93,7 +93,7 @@ impl FastPFor { block_size: N as u32, }); } - Ok(FastPFor { + Ok(Self { bytes_container: BytesMut::with_capacity( (3 * page_size / N as u32 + page_size) as usize, ), diff --git a/src/rust/integer_compression/just_copy.rs b/src/rust/integer_compression/just_copy.rs index ba911f0..767ad11 100644 --- a/src/rust/integer_compression/just_copy.rs +++ b/src/rust/integer_compression/just_copy.rs @@ -5,20 +5,14 @@ use crate::helpers::AsUsize; /// A no-op codec that copies data without compression. /// /// Useful as a baseline for benchmarking or when a codec interface is required. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct JustCopy; impl JustCopy { /// Creates a new instance #[must_use] pub fn new() -> Self { - JustCopy - } -} - -impl Default for JustCopy { - fn default() -> Self { - JustCopy::new() + Self } } diff --git a/src/rust/integer_compression/variable_byte.rs b/src/rust/integer_compression/variable_byte.rs index 4550d04..8c6b2f2 100644 --- a/src/rust/integer_compression/variable_byte.rs +++ b/src/rust/integer_compression/variable_byte.rs @@ -8,7 +8,7 @@ use crate::rust::cursor::IncrementCursor; use crate::{FastPForError, FastPForResult}; /// Variable-byte encoding codec for integer compression. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct VariableByte; // Helper functions with const generics for extracting 7-bit chunks @@ -28,8 +28,8 @@ impl VariableByte { impl VariableByte { /// Creates a new instance #[must_use] - pub fn new() -> VariableByte { - VariableByte + pub fn new() -> Self { + Self } /// Compress `input_length` u32 values from `input[input_offset..]` into @@ -301,12 +301,6 @@ impl VariableByte { } } -impl Default for VariableByte { - fn default() -> Self { - VariableByte::new() - } -} - impl AnyLenCodec for VariableByte { fn encode(&mut self, input: &[u32], out: &mut Vec) -> FastPForResult<()> { let capacity = input.len() * 2 + 4; @@ -314,7 +308,7 @@ impl AnyLenCodec for VariableByte { out.resize(start + capacity, 0); let mut in_off = Cursor::new(0u32); let mut out_off = Cursor::new(0u32); - VariableByte::compress_into_slice( + Self::compress_into_slice( input, input.len() as u32, &mut in_off, @@ -342,7 +336,7 @@ impl AnyLenCodec for VariableByte { out.resize(start + capacity, 0); let mut in_off = Cursor::new(0u32); let mut out_off = Cursor::new(0u32); - VariableByte::decompress_from_u32_slice( + Self::decompress_from_u32_slice( input, input.len() as u32, &mut in_off,