From 458248e4660c7d097c15f96f2084157b22c5cb27 Mon Sep 17 00:00:00 2001 From: Kaley Main Date: Sun, 3 Nov 2024 12:28:30 +1100 Subject: [PATCH] style: clean up needless clippy warnings --- src/cli.rs | 1 - src/lib.rs | 10 ++++------ src/main.rs | 1 - src/mask.rs | 18 +++++++++++++++++- src/wasm.rs | 1 - 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 32cf1b2..38582a7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,4 +1,3 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] use catppuccin_catwalk::Layout; use clap::{Command, Parser, Subcommand, ValueEnum}; use clap_complete::{generate, Generator, Shell}; diff --git a/src/lib.rs b/src/lib.rs index 112c431..d58ed79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,7 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] -// ignore u32 -> f32 & vice versa for now +// ignore u32 -> f32 & vice versa #![allow( - clippy::cast_possible_truncation, clippy::cast_precision_loss, + clippy::cast_possible_truncation, clippy::cast_sign_loss )] @@ -99,7 +98,6 @@ impl Catwalk { } #[must_use] - #[allow(clippy::missing_const_for_fn)] pub fn aa_level(mut self, aa_level: Option) -> Self { let Some(aa_level) = aa_level else { return self; @@ -108,7 +106,6 @@ impl Catwalk { self } - #[allow(clippy::missing_const_for_fn)] #[must_use] pub fn gap(mut self, gap: Option) -> Self { let Some(gap) = gap else { @@ -128,7 +125,6 @@ impl Catwalk { /// Sets the radius of the rounding mask. /// # Errors /// Returns an error if the height or width are not set (automatically inferred from the `new` method arguments) - #[allow(clippy::use_self)] pub fn radius(mut self, radius: Option) -> Result { let radius = radius.unwrap_or(self.radius); @@ -199,6 +195,7 @@ impl Magic { .rev() .map(|(i, x)| Self::gen_mask(w, i, 2, inverse_slope).mask(x)) .collect(); + let mut result = Image::new(self.width, self.height, Rgba::default()) .with_overlay_mode(OverlayMode::Merge); for mask in masked.iter().as_ref() { @@ -267,6 +264,7 @@ impl Magic { }); result } + /// Generates a mask for the given image. fn gen_mask(w: f32, index: usize, aa_level: u32, inverse_slope: f32) -> TrapMask { if index == 3 { diff --git a/src/main.rs b/src/main.rs index 97a70c1..73cca85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] mod cli; use catppuccin_catwalk::Catwalk; diff --git a/src/mask.rs b/src/mask.rs index e6053e9..528b393 100644 --- a/src/mask.rs +++ b/src/mask.rs @@ -1,5 +1,5 @@ // all of the stuff is named ...Mask here -#![allow(clippy::module_name_repetitions)] +#![allow(clippy::module_name_repetitions, clippy::cast_precision_loss)] use ril::prelude::*; @@ -100,3 +100,19 @@ impl TrapMask { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_dis() { + let point_1 = (1u32, 2u32); + let point_2 = (4u32, 2u32); + assert_eq!(RoundMask::get_dis(point_1, point_2), 9); + + let point_1 = (1u32, 1u32); + let point_2 = (1u32, 1u32); + assert_eq!(RoundMask::get_dis(point_1, point_2), 0); + } +} diff --git a/src/wasm.rs b/src/wasm.rs index 69d641f..bc7bce1 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -1,5 +1,4 @@ // needed for WASM -#![allow(clippy::use_self, clippy::missing_const_for_fn)] use crate::{Catwalk, CatwalkError, Magic}; use ril::{Image, Rgba};