Skip to content

Commit 5414013

Browse files
authored
Clippy (#2390)
1 parent 7495e4b commit 5414013

File tree

7 files changed

+10
-22
lines changed

7 files changed

+10
-22
lines changed

deny.toml

+1-9
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ allow = [
1919
"BSD-2-Clause",
2020
"BSD-3-Clause",
2121
"MIT",
22-
"MIT-0",
23-
"MPL-2.0",
24-
"Unicode-DFS-2016",
22+
"Unicode-3.0",
2523
]
2624

27-
[[licenses.exceptions]]
28-
allow = ["WTFPL"]
29-
name = "pcx"
30-
version = "*"
31-
3225
[advisories]
3326
yanked = "deny"
3427
ignore = []
@@ -41,5 +34,4 @@ deny = []
4134
skip = [
4235
{ name = "bitflags" }, # Some deps depend on 1.3.2 while others on 2.6.0
4336
{ name = "hashbrown" }, # Some deps depend on 0.13.2 while others on 0.14.5
44-
{ name = "miniz_oxide" } # Some deps depend on 0.7.4 while others on 0.8.0
4537
]

src/buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ where
801801
/// the bounds will not overflow.
802802
fn check_image_fits(width: u32, height: u32, len: usize) -> bool {
803803
let checked_len = Self::image_buffer_len(width, height);
804-
checked_len.map_or(false, |min_len| min_len <= len)
804+
checked_len.is_some_and(|min_len| min_len <= len)
805805
}
806806

807807
fn image_buffer_len(width: u32, height: u32) -> Option<usize> {

src/codecs/avif/yuv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ fn process_halved_chroma_row<
528528
// preventing accidental use of invalid values from the trailing region.
529529

530530
let y_plane = &image.y_plane[0..image.width];
531-
let chroma_size = image.width.div_ceil(2);
531+
let chroma_size = (image.width + 1) / 2;
532532
let u_plane = &image.u_plane[0..chroma_size];
533533
let v_plane = &image.v_plane[0..chroma_size];
534534
let rgba = &mut rgba[0..image.width * CHANNELS];

src/codecs/pnm/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ where
692692

693693
let token = reader
694694
.bytes()
695-
.skip_while(|v| v.as_ref().ok().map_or(false, is_separator))
696-
.take_while(|v| v.as_ref().ok().map_or(false, |c| !is_separator(c)))
695+
.skip_while(|v| v.as_ref().ok().is_some_and(is_separator))
696+
.take_while(|v| v.as_ref().ok().is_some_and(|c| !is_separator(c)))
697697
.collect::<Result<Vec<u8>, _>>()?;
698698

699699
if !token.is_ascii() {

src/color.rs

+1
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ impl<T: Primitive> FromPrimitive<T> for T {
441441
// 1.0 (white) was picked as firefox and chrome choose to map NaN to that.
442442
#[inline]
443443
fn normalize_float(float: f32, max: f32) -> f32 {
444+
#[allow(clippy::neg_cmp_op_on_partial_ord)]
444445
let clamped = if !(float < 1.0) { 1.0 } else { float.max(0.0) };
445446
(clamped * max).round()
446447
}

src/flat.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl SampleLayout {
282282
/// Check if a buffer of length `len` is large enough.
283283
#[must_use]
284284
pub fn fits(&self, len: usize) -> bool {
285-
self.min_length().map_or(false, |min| len >= min)
285+
self.min_length().is_some_and(|min| len >= min)
286286
}
287287

288288
/// The extents of this array, in order of increasing strides.
@@ -747,10 +747,7 @@ impl<Buffer> FlatSamples<Buffer> {
747747
where
748748
Buffer: AsRef<[T]>,
749749
{
750-
let min_length = match self.min_length() {
751-
None => return None,
752-
Some(index) => index,
753-
};
750+
let min_length = self.min_length()?;
754751

755752
let slice = self.samples.as_ref();
756753
if slice.len() < min_length {
@@ -765,10 +762,7 @@ impl<Buffer> FlatSamples<Buffer> {
765762
where
766763
Buffer: AsMut<[T]>,
767764
{
768-
let min_length = match self.min_length() {
769-
None => return None,
770-
Some(index) => index,
771-
};
765+
let min_length = self.min_length()?;
772766

773767
let slice = self.samples.as_mut();
774768
if slice.len() < min_length {

src/imageops/sample.rs

+1
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ where
870870
let max = S::DEFAULT_MAX_VALUE;
871871
let max: f32 = NumCast::from(max).unwrap();
872872

873+
#[allow(clippy::redundant_guards)]
873874
let sum = match kernel.iter().fold(0.0, |s, &item| s + item) {
874875
x if x == 0.0 => 1.0,
875876
sum => sum,

0 commit comments

Comments
 (0)