Skip to content

Commit 81a4239

Browse files
committed
Fix clippy warnings in decoder and reader modules
- Replace manual arithmetic check with saturating_sub - Remove unused lifetime parameter in Reader<Mmap> impl - Remove unused import in test module
1 parent 0f27a5f commit 81a4239

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

src/maxminddb/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'de> Decoder<'de> {
5555
return size;
5656
}
5757

58-
let bytes_to_read = if size > 28 { size - 28 } else { 0 };
58+
let bytes_to_read = size.saturating_sub(28);
5959

6060
let new_offset = self.current_ptr + bytes_to_read;
6161
let size_bytes = &self.buf[self.current_ptr..new_offset];

src/maxminddb/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub struct Reader<S: AsRef<[u8]>> {
209209
}
210210

211211
#[cfg(feature = "mmap")]
212-
impl<'de> Reader<Mmap> {
212+
impl Reader<Mmap> {
213213
/// Open a MaxMind DB database file by memory mapping it.
214214
///
215215
/// # Example

src/maxminddb/reader_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ fn test_reader_readfile() {
179179
#[test]
180180
#[cfg(feature = "mmap")]
181181
fn test_reader_mmap() {
182-
use crate::Mmap;
183182
let _ = env_logger::try_init();
184183

185184
let sizes = [24usize, 28, 32];

0 commit comments

Comments
 (0)