diff options
author | cc <cc@localhost> | 2025-08-28 02:07:47 -0700 |
---|---|---|
committer | cc <cc@localhost> | 2025-08-28 02:09:21 -0700 |
commit | d411b9e6a2b6c185921e2479ba5cd6e2010d5473 (patch) | |
tree | c230ab3cf2bb3db104a284e6c7058b1439a83753 | |
parent | b2bb714ad8287a33a1ee399999e340471b0bb4b4 (diff) |
Pin breaking update
Better trait
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/label_format.rs | 12 | ||||
-rw-r--r-- | src/lib.rs | 2 |
3 files changed, 8 insertions, 8 deletions
@@ -1,6 +1,6 @@ [package] name = "label_toolkit" -version = "0.0.3" +version = "0.1.0" edition = "2024" [dependencies] diff --git a/src/label_format.rs b/src/label_format.rs index c127e81..254cbd6 100644 --- a/src/label_format.rs +++ b/src/label_format.rs @@ -4,18 +4,18 @@ use crate::flood; use crate::color; pub trait LabelU16 { - fn zero(&self) -> Self; + fn is_zero(&self) -> bool; } impl LabelU16 for u16 { - fn zero(&self) -> Self { - 0u16 + fn is_zero(&self) -> bool { + *self == 0u16 } } impl LabelU16 for u32 { - fn zero(&self) -> Self { - 0u32 + fn is_zero(&self) -> bool { + *self == 0u32 } } @@ -41,7 +41,7 @@ impl<T: LabelU16 + PartialEq + Copy> LabelFormat<T> { for y in 0..self.height { for x in 0..self.width { let index = x + y*self.width; - if self.buffer[index] == self.buffer[index].zero() { + if self.buffer[index].is_zero() { continue; } if output_buffer[index] == 0 { @@ -8,7 +8,7 @@ pub(crate) fn flood<T: LabelU16 + PartialEq + Copy, R: LabelU16 + PartialEq + Co from_color: T, to_color: R) { let width = source.width; let destination_color = destination[x + y * width]; - if destination_color != destination_color.zero() { + if !destination_color.is_zero() { return; } let source_color = source.buffer[x + y * width]; |