use objc2::encode::{Encode, Encoding, RefEncode}; use objc2::ffi::NSUInteger;
#[cfg(feature = "objc2-core-foundation")] use objc2_core_foundation::{CGPoint, CGRect, CGSize};
/// A point in a Cartesian coordinate system. /// /// This is a convenience alias for [`CGPoint`]. For ease of use, it is /// available on all platforms, though in practice it is only useful on macOS. /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nspoint?language=objc). #[cfg(feature = "objc2-core-foundation")] pubtype NSPoint = CGPoint;
/// A two-dimensional size. /// /// This is a convenience alias for [`CGSize`]. For ease of use, it is /// available on all platforms, though in practice it is only useful on macOS. /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nssize?language=objc). #[cfg(feature = "objc2-core-foundation")] pubtype NSSize = CGSize;
/// A rectangle. /// /// This is a convenience alias for [`CGRect`]. For ease of use, it is /// available on all platforms, though in practice it is only useful on macOS. /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrect?language=objc). #[cfg(feature = "objc2-core-foundation")] pubtype NSRect = CGRect;
#[cfg(test)] mod tests { // We know the Rust implementation handles NaN, infinite, negative zero // and so on properly, so let's ensure that NSEqualXXX handles these as // well (so that we're confident that the implementations are equivalent). #[test] #[cfg(any(
all(target_vendor = "apple", target_os = "macos"), // or macabi
feature = "gnustep-1-7"
))] #[cfg(feature = "objc2-core-foundation")] fn test_partial_eq() { usesuper::*; usecrate::{NSEqualPoints, NSEqualRects, NSEqualSizes}; use objc2_core_foundation::CGFloat;
// We assume that comparisons handle e.g. `x` and `y` in the same way, // therefore we set the coordinates / dimensions to the same. let cases: &[(CGFloat, CGFloat)] = &[
(0.0, 0.0),
(-0.0, -0.0),
(0.0, -0.0),
(1.0, 1.0 + CGFloat::EPSILON),
(0.0, CGFloat::MIN_POSITIVE),
(0.0, CGFloat::EPSILON),
(1.0, 1.0),
(1.0, -1.0), // Infinity
(CGFloat::INFINITY, CGFloat::INFINITY),
(CGFloat::INFINITY, CGFloat::NEG_INFINITY),
(CGFloat::NEG_INFINITY, CGFloat::NEG_INFINITY), // NaN
(CGFloat::NAN, 0.0),
(CGFloat::NAN, 1.0),
(CGFloat::NAN, CGFloat::NAN),
(CGFloat::NAN, -CGFloat::NAN),
(-CGFloat::NAN, -CGFloat::NAN),
(CGFloat::NAN, CGFloat::INFINITY),
];
for case in cases { let point_a = NSPoint::new(case.0, case.1); let point_b = NSPoint::new(case.0, case.1); let actual = NSEqualPoints(point_a, point_b);
assert_eq!(point_a == point_b, actual);
if case.0 >= 0.0 && case.1 >= 0.0 { let size_a = NSSize::new(case.0, case.1); let size_b = NSSize::new(case.0, case.1); let actual = NSEqualSizes(size_a, size_b);
assert_eq!(size_a == size_b, actual);
let rect_a = NSRect::new(point_a, size_a); let rect_b = NSRect::new(point_b, size_b); let actual = NSEqualRects(rect_a, rect_b);
assert_eq!(rect_a == rect_b, actual);
}
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-10-02)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.