Implement Eq for all types

This commit is contained in:
ratake
2017-11-07 20:44:12 -08:00
parent a1125852db
commit d20b8abc9c
3 changed files with 18 additions and 1 deletions
-1
View File
@@ -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;
+9
View File
@@ -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 {
+9
View File
@@ -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 { }
}
}