Skip to content

Commit

Permalink
glib: Implement Hash for WeakRef
Browse files Browse the repository at this point in the history
  • Loading branch information
A6GibKm committed Jan 28, 2021
1 parent 8096e5b commit ed5ceaa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions glib/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,12 @@ glib_wrapper! {
#[derive(Debug)]
pub struct WeakRef<T: ObjectType>(Pin<Box<gobject_ffi::GWeakRef>>, PhantomData<*mut T>);

impl<T: ObjectType> hash::Hash for WeakRef<T> {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe { self.0.priv_.p.hash(state) }
}
}

impl<T: ObjectType> PartialEq for WeakRef<T> {
fn eq(&self, other: &Self) -> bool {
unsafe { self.0.priv_.p == other.0.priv_.p }
Expand Down

0 comments on commit ed5ceaa

Please sign in to comment.