Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Sep 10, 2023
1 parent 3e59c76 commit 0b58ead
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl Attributes {
pub(crate) fn verbose_print(self: &Attributes, msg: impl AsRef<str>) {
fn _print(a: &Attributes, msg: &str) {
if let Some(f) = &a.log_callback {
f(a, msg)
f(a, msg);
}
}
_print(self, msg.as_ref());
Expand All @@ -270,7 +270,7 @@ impl Attributes {
#[inline]
pub(crate) fn verbose_printf_flush(self: &Attributes) {
if let Some(f) = &self.log_flush_callback {
f(self)
f(self);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/hist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub(crate) struct U32Hasher(pub u32);
impl std::hash::Hasher for U32Hasher {
// magic constant from fxhash. For a single 32-bit key that's all it needs!
#[inline(always)]
fn finish(&self) -> u64 { (self.0 as u64).wrapping_mul(0x517cc1b727220a95) }
fn finish(&self) -> u64 { u64::from(self.0).wrapping_mul(0x517cc1b727220a95) }
#[inline(always)]
fn write_u32(&mut self, i: u32) { self.0 = i; }

Expand All @@ -425,7 +425,7 @@ pub(crate) struct HashColor { pub rgba: RGBA, pub index: PalIndex }
impl Hash for HashColor {
#[inline]
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
u32::from_ne_bytes(self.rgba.as_slice().try_into().unwrap()).hash(state)
u32::from_ne_bytes(self.rgba.as_slice().try_into().unwrap()).hash(state);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
//! See `examples/` directory for example code.
#![doc(html_logo_url = "https://pngquant.org/pngquant-logo.png")]
#![deny(missing_docs)]
#![allow(clippy::if_not_else)]
#![allow(clippy::inline_always)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::redundant_closure_for_method_calls)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::wildcard_imports)]
#![deny(clippy::semicolon_if_nothing_returned)]

mod attr;
mod blur;
Expand Down
4 changes: 2 additions & 2 deletions src/pal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub(crate) struct PalPop(f32);

impl PalPop {
#[inline(always)]
pub fn is_fixed(&self) -> bool {
pub fn is_fixed(self) -> bool {
self.0 < 0.
}

Expand All @@ -195,7 +195,7 @@ impl PalPop {
}

#[inline(always)]
pub fn popularity(&self) -> f32 {
pub fn popularity(self) -> f32 {
self.0.abs()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/remap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn remap_to_palette<'x, 'b: 'x>(px: &mut DynamicRows, background: Opt
}
remapping_error += f64::from(diff);
out.write(matched);
let importance = importance_map.get(col).copied().unwrap_or(1) as f32;
let importance = f32::from(importance_map.get(col).copied().unwrap_or(1));
kmeans.update_color(*inp, importance, matched as _);
}
remapping_error
Expand Down

0 comments on commit 0b58ead

Please sign in to comment.