Skip to content

Commit

Permalink
Merge pull request #69 from sile/fix-clippy-warnings-0.1.67
Browse files Browse the repository at this point in the history
Fix clippy (v0.1.67) warnings
  • Loading branch information
sile authored Feb 6, 2023
2 parents adc8146 + aba8290 commit 0c11c3e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
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

0 comments on commit 0c11c3e

Please sign in to comment.