mtl_foundation/
objc_runtime.rs1use crate::types::{INTEGER_MAX, Integer};
20
21#[repr(transparent)]
25#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)]
26pub struct ComparisonResult(pub Integer);
27
28impl ComparisonResult {
29 pub const ORDERED_ASCENDING: Self = Self(-1);
33
34 pub const ORDERED_SAME: Self = Self(0);
38
39 pub const ORDERED_DESCENDING: Self = Self(1);
43
44 #[inline]
46 pub const fn raw(&self) -> Integer {
47 self.0
48 }
49
50 #[inline]
52 pub const fn from_raw(value: Integer) -> Self {
53 Self(value)
54 }
55}
56
57impl From<Integer> for ComparisonResult {
58 #[inline]
59 fn from(value: Integer) -> Self {
60 Self(value)
61 }
62}
63
64impl From<ComparisonResult> for Integer {
65 #[inline]
66 fn from(value: ComparisonResult) -> Self {
67 value.0
68 }
69}
70
71pub const NOT_FOUND: Integer = INTEGER_MAX;
75
76#[cfg(test)]
77mod tests {
78 use super::*;
79
80 #[test]
81 fn test_comparison_result_values() {
82 assert_eq!(ComparisonResult::ORDERED_ASCENDING.raw(), -1);
83 assert_eq!(ComparisonResult::ORDERED_SAME.raw(), 0);
84 assert_eq!(ComparisonResult::ORDERED_DESCENDING.raw(), 1);
85 }
86
87 #[test]
88 fn test_not_found() {
89 assert_eq!(NOT_FOUND, isize::MAX);
90 }
91}