diff options
author | 2023-04-05 05:47:29 +0200 | |
---|---|---|
committer | 2023-04-05 05:47:29 +0200 | |
commit | 4cae262d22cde458cbb5d0667e4bcf6adce9242a (patch) | |
tree | 6f39f0fb6df8a9e0c8514d3d60d0c59d5eadfe61 /core/src/image.rs | |
parent | f8cd1faa286daaf34cc532bf6d34b932b32eb35a (diff) | |
download | iced-4cae262d22cde458cbb5d0667e4bcf6adce9242a.tar.gz iced-4cae262d22cde458cbb5d0667e4bcf6adce9242a.tar.bz2 iced-4cae262d22cde458cbb5d0667e4bcf6adce9242a.zip |
Implement `PartialEq` and `Eq` for `image::Bytes`
Diffstat (limited to 'core/src/image.rs')
-rw-r--r-- | core/src/image.rs | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/core/src/image.rs b/core/src/image.rs index 618235ef..85d9d475 100644 --- a/core/src/image.rs +++ b/core/src/image.rs @@ -110,6 +110,14 @@ impl std::hash::Hash for Bytes { } } +impl PartialEq for Bytes { + fn eq(&self, other: &Self) -> bool { + self.as_ref() == other.as_ref() + } +} + +impl Eq for Bytes {} + impl AsRef<[u8]> for Bytes { fn as_ref(&self) -> &[u8] { self.0.as_ref().as_ref() @@ -125,7 +133,7 @@ impl std::ops::Deref for Bytes { } /// The data of a raster image. -#[derive(Clone, Hash)] +#[derive(Clone, PartialEq, Eq, Hash)] pub enum Data { /// File data Path(PathBuf), @@ -156,34 +164,6 @@ impl std::fmt::Debug for Data { } } -impl PartialEq for Data { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Path(a), Self::Path(b)) => a == b, - (Self::Bytes(a), Self::Bytes(b)) => a.as_ref() == b.as_ref(), - ( - Self::Rgba { - width: width_a, - height: height_a, - pixels: pixels_a, - }, - Self::Rgba { - width: width_b, - height: height_b, - pixels: pixels_b, - }, - ) => { - width_a == width_b - && height_a == height_b - && pixels_a.as_ref() == pixels_b.as_ref() - } - _ => false, - } - } -} - -impl Eq for Data {} - /// A [`Renderer`] that can render raster graphics. /// /// [renderer]: crate::renderer |