Skip to content

Commit

Permalink
client: Implement Eq for Connection
Browse files Browse the repository at this point in the history
This is useful in some cases, and there's no harm to providing it.
  • Loading branch information
ids1024 authored and elinorbgr committed Nov 9, 2023
1 parent fe45e89 commit 1e30de0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions wayland-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Additions
- client: Implement `Eq` for `Backend`

## 0.3.2 -- 2023-09-25

#### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/client_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl ObjectId {
///
/// This type hosts all the interface for interacting with the wayland protocol. It can be
/// cloned, all clones refer to the same underlying connection.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Backend {
pub(crate) backend: client_impl::InnerBackend,
}
Expand Down
8 changes: 8 additions & 0 deletions wayland-backend/src/rs/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ impl WeakInnerBackend {
}
}

impl PartialEq for InnerBackend {
fn eq(&self, rhs: &Self) -> bool {
Arc::ptr_eq(&self.state, &rhs.state)
}
}

impl Eq for InnerBackend {}

impl InnerBackend {
pub fn downgrade(&self) -> WeakInnerBackend {
WeakInnerBackend { state: Arc::downgrade(&self.state) }
Expand Down
8 changes: 8 additions & 0 deletions wayland-backend/src/sys/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ impl WeakInnerBackend {
}
}

impl PartialEq for InnerBackend {
fn eq(&self, rhs: &Self) -> bool {
Arc::ptr_eq(&self.inner, &rhs.inner)
}
}

impl Eq for InnerBackend {}

unsafe impl Send for InnerBackend {}
unsafe impl Sync for InnerBackend {}

Expand Down
3 changes: 3 additions & 0 deletions wayland-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

#### Additions
- Implement `Eq` for `Connection`

## 0.31.1 -- 2023-09-19

#### Additions
Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{protocol::wl_display::WlDisplay, EventQueue, Proxy};
/// In case you need to plug yourself into an external Wayland connection that you don't control, you'll
/// likely get access to it as a [`Backend`], in which case you can create a [`Connection`] from it using
/// the [`from_backend`](Connection::from_backend) method.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Connection {
pub(crate) backend: Backend,
}
Expand Down

0 comments on commit 1e30de0

Please sign in to comment.