Implement PartialEq and Eq for image::Bytes
This commit is contained in:
parent
f8cd1faa28
commit
4cae262d22
1 changed files with 9 additions and 29 deletions
|
|
@ -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 {
|
impl AsRef<[u8]> for Bytes {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
self.0.as_ref().as_ref()
|
self.0.as_ref().as_ref()
|
||||||
|
|
@ -125,7 +133,7 @@ impl std::ops::Deref for Bytes {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The data of a raster image.
|
/// The data of a raster image.
|
||||||
#[derive(Clone, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum Data {
|
pub enum Data {
|
||||||
/// File data
|
/// File data
|
||||||
Path(PathBuf),
|
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.
|
/// A [`Renderer`] that can render raster graphics.
|
||||||
///
|
///
|
||||||
/// [renderer]: crate::renderer
|
/// [renderer]: crate::renderer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue