fix: resolve clippy warnings for Copy type methods
Some checks failed
CI / test (push) Failing after 9m51s
Some checks failed
CI / test (push) Failing after 9m51s
Change to_* methods to take self by value instead of &self Since Color implements Copy, these methods should follow the clippy::wrong_self_convention lint recommendation 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
12
src/color.rs
12
src/color.rs
@@ -79,7 +79,7 @@ impl Color {
|
|||||||
Color::from_rgb(r + m, g + m, b + m)
|
Color::from_rgb(r + m, g + m, b + m)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_hex(&self) -> String {
|
pub fn to_hex(self) -> String {
|
||||||
if self.a < 1.0 {
|
if self.a < 1.0 {
|
||||||
format!(
|
format!(
|
||||||
"#{:02x}{:02x}{:02x}{:02x}",
|
"#{:02x}{:02x}{:02x}{:02x}",
|
||||||
@@ -98,7 +98,7 @@ impl Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_hsl(&self) -> (f64, f64, f64) {
|
pub fn to_hsl(self) -> (f64, f64, f64) {
|
||||||
let max = self.r.max(self.g).max(self.b);
|
let max = self.r.max(self.g).max(self.b);
|
||||||
let min = self.r.min(self.g).min(self.b);
|
let min = self.r.min(self.g).min(self.b);
|
||||||
let delta = max - min;
|
let delta = max - min;
|
||||||
@@ -128,7 +128,7 @@ impl Color {
|
|||||||
(h, s, l)
|
(h, s, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_hsv(&self) -> (f64, f64, f64) {
|
pub fn to_hsv(self) -> (f64, f64, f64) {
|
||||||
let max = self.r.max(self.g).max(self.b);
|
let max = self.r.max(self.g).max(self.b);
|
||||||
let min = self.r.min(self.g).min(self.b);
|
let min = self.r.min(self.g).min(self.b);
|
||||||
let delta = max - min;
|
let delta = max - min;
|
||||||
@@ -155,7 +155,7 @@ impl Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert RGB to XYZ (D65 illuminant)
|
// Convert RGB to XYZ (D65 illuminant)
|
||||||
fn to_xyz(&self) -> (f64, f64, f64) {
|
fn to_xyz(self) -> (f64, f64, f64) {
|
||||||
let r = if self.r > 0.04045 {
|
let r = if self.r > 0.04045 {
|
||||||
((self.r + 0.055) / 1.055).powf(2.4)
|
((self.r + 0.055) / 1.055).powf(2.4)
|
||||||
} else {
|
} else {
|
||||||
@@ -181,7 +181,7 @@ impl Color {
|
|||||||
(x * 100.0, y * 100.0, z * 100.0)
|
(x * 100.0, y * 100.0, z * 100.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_lab(&self) -> (f64, f64, f64) {
|
pub fn to_lab(self) -> (f64, f64, f64) {
|
||||||
let (x, y, z) = self.to_xyz();
|
let (x, y, z) = self.to_xyz();
|
||||||
|
|
||||||
let x = x / 95.047;
|
let x = x / 95.047;
|
||||||
@@ -203,7 +203,7 @@ impl Color {
|
|||||||
(l, a, b)
|
(l, a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_lch(&self) -> (f64, f64, f64) {
|
pub fn to_lch(self) -> (f64, f64, f64) {
|
||||||
let (l, a, b) = self.to_lab();
|
let (l, a, b) = self.to_lab();
|
||||||
let c = (a * a + b * b).sqrt();
|
let c = (a * a + b * b).sqrt();
|
||||||
let h = b.atan2(a).to_degrees();
|
let h = b.atan2(a).to_degrees();
|
||||||
|
|||||||
Reference in New Issue
Block a user