Skip to content

Commit

Permalink
Fix a subset of issues identified by cargo clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
anforowicz authored and kornelski committed Oct 6, 2024
1 parent 657f75b commit 1764d16
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/decoder/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl StreamingDecoder {
_ => Ok(Decoded::PartialChunk(type_str)),
};

let parse_result = parse_result.map_err(|e| {
parse_result.map_err(|e| {
self.state = None;
match e {
// `parse_chunk` is invoked after gathering **all** bytes of a chunk, so
Expand All @@ -972,9 +972,7 @@ impl StreamingDecoder {
}
e => e,
}
});

parse_result
})
}

fn parse_fctl(&mut self) -> Result<Decoded, DecodingError> {
Expand Down
8 changes: 4 additions & 4 deletions src/decoder/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ pub fn create_transform_fn(
match color_type {
ColorType::Indexed if expand => {
if info.palette.is_none() {
return Err(DecodingError::Format(
Err(DecodingError::Format(
FormatErrorInner::PaletteRequired.into(),
));
))
} else if let BitDepth::Sixteen = info.bit_depth {
// This should have been caught earlier but let's check again. Can't hurt.
return Err(DecodingError::Format(
Err(DecodingError::Format(
FormatErrorInner::InvalidColorBitDepth {
color_type: ColorType::Indexed,
bit_depth: BitDepth::Sixteen,
}
.into(),
));
))
} else {
Ok(if trns {
palette::create_expansion_into_rgba8(info)
Expand Down
4 changes: 2 additions & 2 deletions src/decoder/transform/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn create_rgba_palette(info: &Info) -> [[u8; 4]; 256] {
palette_iter = &palette_iter[3..];
rgba_iter = &mut rgba_iter[1..];
}
if palette_iter.len() > 0 {
if !palette_iter.is_empty() {
rgba_iter[0][0..3].copy_from_slice(&palette_iter[0..3]);
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ fn expand_8bit_into_rgb8(mut input: &[u8], mut output: &mut [u8], rgba_palette:
input = &input[1..];
output = &mut output[3..];
}
if output.len() > 0 {
if !output.is_empty() {
let rgba = &rgba_palette[input[0] as usize];
output[0..3].copy_from_slice(&rgba[0..3]);
}
Expand Down
1 change: 0 additions & 1 deletion src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ impl<'a, W: Write> Encoder<'a, W> {
/// based on heuristics which minimize the file size for compression rather
/// than use a single filter for the entire image. The default method is
/// [`AdaptiveFilterType::NonAdaptive`].

pub fn set_adaptive_filter(&mut self, adaptive_filter: AdaptiveFilterType) {
self.options.adaptive_filter = adaptive_filter;
}
Expand Down

0 comments on commit 1764d16

Please sign in to comment.