Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: clean up needless clippy warnings #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
)]

Expand Down Expand Up @@ -99,7 +98,6 @@ impl Catwalk {
}

#[must_use]
#[allow(clippy::missing_const_for_fn)]
pub fn aa_level(mut self, aa_level: Option<u32>) -> Self {
let Some(aa_level) = aa_level else {
return self;
Expand All @@ -108,7 +106,6 @@ impl Catwalk {
self
}

#[allow(clippy::missing_const_for_fn)]
#[must_use]
pub fn gap(mut self, gap: Option<u32>) -> Self {
let Some(gap) = gap else {
Expand All @@ -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<u32>) -> Result<Catwalk, CatwalkError> {
let radius = radius.unwrap_or(self.radius);

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![deny(clippy::perf, clippy::nursery, clippy::pedantic)]
mod cli;

use catppuccin_catwalk::Catwalk;
Expand Down
18 changes: 17 additions & 1 deletion src/mask.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down Expand Up @@ -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);
}
}
1 change: 0 additions & 1 deletion src/wasm.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down