Skip to content

Commit

Permalink
PartialEq for AnyTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Oct 3, 2024
1 parent 6506594 commit cbc01e7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
32 changes: 19 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,14 @@ impl sealed::TextureSource for TextureCollection {
}
}

impl PartialEq for TextureCollection {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.data, &other.data)
}
}

/// A texture that is contained within a [`TextureCollection`].
#[derive(Clone)]
#[derive(Clone, PartialEq)]
pub struct CollectedTexture {
collection: TextureCollection,
id: Arc<LotId>,
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,12 @@ impl Texture {
}
}

impl PartialEq for Texture {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

/// Loads a texture's bytes into the executable. This macro returns a result
/// containing a [`LazyTexture`].
///
Expand Down Expand Up @@ -2083,7 +2089,7 @@ impl From<ShareableTexture> for TextureRegion {
/// This type is useful if you are designing a type that supports drawing a
/// configurable texture, but you don't care whether it's a [`Texture`],
/// [`SharedTexture`], [`TextureRegion`], or [`CollectedTexture`].
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum AnyTexture {
/// A [`Texture`].
Texture(Texture),
Expand Down

0 comments on commit cbc01e7

Please sign in to comment.