diff --git a/core-foundation-sys/src/base.rs b/core-foundation-sys/src/base.rs index 03f81ba..71d1ec9 100644 --- a/core-foundation-sys/src/base.rs +++ b/core-foundation-sys/src/base.rs @@ -93,7 +93,6 @@ extern { //fn CFCopyDescription //fn CFCopyTypeIDDescription - //fn CFEqual //fn CFGetAllocator pub fn CFEqual(cf1: CFTypeRef, cf2: CFTypeRef) -> Boolean; pub fn CFGetRetainCount(cf: CFTypeRef) -> CFIndex; diff --git a/core-foundation/src/base.rs b/core-foundation/src/base.rs index 5e55b8b..308761c 100644 --- a/core-foundation/src/base.rs +++ b/core-foundation/src/base.rs @@ -38,6 +38,15 @@ impl Clone for CFType { } } +impl PartialEq for CFType { + #[inline] + fn eq(&self, other: &CFType) -> bool { + unsafe { + CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0 + } + } +} + impl Drop for CFType { fn drop(&mut self) { unsafe { diff --git a/core-foundation/src/lib.rs b/core-foundation/src/lib.rs index f4ca71d..0495b7b 100644 --- a/core-foundation/src/lib.rs +++ b/core-foundation/src/lib.rs @@ -45,6 +45,15 @@ macro_rules! impl_TCFType { } } } + + impl PartialEq for $ty { + #[inline] + fn eq(&self, other: &$ty) -> bool { + self.as_CFType().eq(&other.as_CFType()) + } + } + + impl Eq for $ty { } } }