Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy (v0.1.67) warnings #69

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/deflate/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ where
if used != len.into() {
Err(io::Error::new(
io::ErrorKind::UnexpectedEof,
format!(
"The reader has incorrect length: expected {}, read {}",
len, used
),
format!("The reader has incorrect length: expected {len}, read {used}"),
))
} else {
Ok(())
Expand Down
7 changes: 3 additions & 4 deletions src/deflate/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl Decoder {
0..=255 => Symbol::Code(lz77::Code::Literal(decoded as u8)),
256 => Symbol::EndOfBlock,
286 | 287 => {
let message = format!("The value {} must not occur in compressed data", decoded);
let message = format!("The value {decoded} must not occur in compressed data");
reader.set_last_error(io::Error::new(io::ErrorKind::InvalidData, message));
Symbol::EndOfBlock // dummy value
}
Expand Down Expand Up @@ -392,8 +392,7 @@ impl HuffmanCodec for DynamicHuffmanCodec {

if distance_code_count as usize > MAX_DISTANCE_CODE_COUNT {
let message = format!(
"The value of HDIST is too big: max={}, actual={}",
MAX_DISTANCE_CODE_COUNT, distance_code_count
"The value of HDIST is too big: max={MAX_DISTANCE_CODE_COUNT}, actual={distance_code_count}"
);
return Err(io::Error::new(io::ErrorKind::InvalidData, message));
}
Expand Down Expand Up @@ -491,7 +490,7 @@ fn build_bitwidth_codes(
(&codec.literal, literal_code_count),
(&codec.distance, distance_code_count),
] {
for (i, c) in (0..size).map(|x| e.lookup(x as u16).width).enumerate() {
for (i, c) in (0..size).map(|x| e.lookup(x).width).enumerate() {
if i > 0 && run_lens.last().map_or(false, |s| s.value == c) {
run_lens.last_mut().unwrap().count += 1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl Decoder {
}
peek_bitwidth = bitwidth;
}
reader.skip_bits(bitwidth as u8);
reader.skip_bits(bitwidth);
value >> 5
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/non_blocking/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<R: Read> Read for TransactionalReader<R> {
if self.offset < self.buffer.len() {
let unread_buf_size = self.buffer.len() - self.offset;
let size = cmp::min(buf.len(), unread_buf_size);
(&mut buf[0..size]).copy_from_slice(&self.buffer[self.offset..self.offset + size]);
buf[0..size].copy_from_slice(&self.buffer[self.offset..self.offset + size]);
self.offset += size;
return Ok(size);
}
Expand Down
8 changes: 2 additions & 6 deletions src/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,18 @@ impl Lz77WindowSize {
/// - [Zlib Flush Modes](https://www.bolet.org/~pornin/deflate-flush.html)
///
/// [zlib]: https://www.zlib.net/
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum FlushMode {
/// `Z_NO_FLUSH` (default).
///
/// Note that when this parameter is specified,
/// no `zlib` specific processing will not be executed but ordinal DEFLATE layer flushing will be performed.
#[default]
None = 0,

/// `Z_SYNC_FLUSH`.
Sync = 2,
}
impl Default for FlushMode {
fn default() -> Self {
FlushMode::None
}
}

/// ZLIB header.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down