Skip to content

Commit

Permalink
Fix clippy::use_self
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Aug 5, 2024
1 parent 73c01ec commit 22391b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ clippy.missing_errors_doc = "warn"
clippy.missing_panics_doc = "warn"
clippy.partial_pub_fields = "warn"
clippy.shadow_unrelated = "warn"
# clippy.use_self = "warn"
clippy.use_self = "warn"

# This catches duplicated dependencies in the tree, which we don't have much control over
# We should use cargo deny for this, anyway
Expand Down
8 changes: 4 additions & 4 deletions src/brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ impl Brush {
/// Returns the brush with the alpha component multiplied by the specified
/// factor.
#[must_use]
pub fn with_alpha_factor(self, alpha: f32) -> Brush {
pub fn with_alpha_factor(self, alpha: f32) -> Self {
if alpha == 1.0 {
self
} else {
match self {
Brush::Solid(color) => color.with_alpha_factor(alpha).into(),
Brush::Gradient(mut gradient) => {
Self::Solid(color) => color.with_alpha_factor(alpha).into(),
Self::Gradient(mut gradient) => {
gradient
.stops
.iter_mut()
.for_each(|stop| *stop = stop.with_alpha_factor(alpha));
gradient.into()
}
Brush::Image(image) => image.with_alpha_factor(alpha).into(),
Self::Image(image) => image.with_alpha_factor(alpha).into(),
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Color {
#[allow(clippy::many_single_char_names)]
#[allow(clippy::unreadable_literal)]
#[must_use]
pub fn hlca(h: f64, l: f64, c: f64, alpha: f64) -> Color {
pub fn hlca(h: f64, l: f64, c: f64, alpha: f64) -> Self {
// The reverse transformation from Lab to XYZ, see
// https://en.wikipedia.org/wiki/CIELAB_color_space
fn f_inv(t: f64) -> f64 {
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Color {
1.055 * u.powf(1. / 2.4) - 0.055
}
}
Color::rgba(gamma(r_lin), gamma(g_lin), gamma(b_lin), alpha)
Self::rgba(gamma(r_lin), gamma(g_lin), gamma(b_lin), alpha)
}

/// Parses a color from a string.
Expand Down Expand Up @@ -160,6 +160,7 @@ impl Color {
}

/// Named SVG colors.
#[allow(clippy::use_self)]
impl Color {
/// Alice blue (240, 248, 255, 255)
pub const ALICE_BLUE: Color = Color::rgba8(240, 248, 255, 255);
Expand Down

0 comments on commit 22391b3

Please sign in to comment.