From 69c20d4ab9de81fbb3d9d14c152615a9654d43ca Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Fri, 17 Feb 2023 02:08:36 +0100 Subject: [PATCH] Implement PartialEq and PartialOrd for WeakRef --- glib/src/object.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/glib/src/object.rs b/glib/src/object.rs index 6ad5f1017f23..f68780b4ca1f 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -3454,6 +3454,27 @@ impl Default for WeakRef { unsafe impl Sync for WeakRef {} unsafe impl Send for WeakRef {} +impl PartialEq for WeakRef { + #[inline] + fn eq(&self, other: &Self) -> bool { + unsafe { self.0.priv_.p == other.0.priv_.p } + } +} + +impl PartialEq for WeakRef { + #[inline] + fn eq(&self, other: &T) -> bool { + unsafe { self.0.priv_.p == other.as_ptr() as *mut std::os::raw::c_void } + } +} + +impl PartialOrd for WeakRef { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + unsafe { self.0.priv_.p.partial_cmp(&other.0.priv_.p) } + } +} + // rustdoc-stripper-ignore-next /// A weak reference to the object it was created for that can be sent to /// different threads even for object types that don't implement `Send`.