diff options
-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]; |