Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit f9f2226

Browse files
Add a couple additional CGRect functions
1 parent c60afb8 commit f9f2226

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/geometry.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ impl CGRect {
8585
Some(rect)
8686
}
8787
}
88+
89+
#[inline]
90+
pub fn is_empty(&self) -> bool {
91+
unsafe {
92+
// I use one, as it seems that `YES` is not available from this crate.
93+
ffi::CGRectIsEmpty(*self) == 1
94+
}
95+
}
96+
97+
#[inline]
98+
pub fn is_intersects(&self, other: &CGRect) -> bool {
99+
unsafe {
100+
// I use one, as it seems that `YES` is not available from this crate.
101+
ffi::CGRectIntersectsRect(*self, *other) == 1
102+
}
103+
}
88104
}
89105

90106
mod ffi {
@@ -97,6 +113,8 @@ mod ffi {
97113
pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect;
98114
pub fn CGRectMakeWithDictionaryRepresentation(dict: CFDictionaryRef,
99115
rect: *mut CGRect) -> boolean_t;
116+
pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t;
117+
pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t;
100118
}
101119
}
102120

0 commit comments

Comments
 (0)