rust_macios/foundation/ns_number.rs
1use std::ops::Add;
2
3use libc::{
4 c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong,
5 c_ulonglong, c_ushort,
6};
7use objc::{msg_send, sel, sel_impl};
8
9use crate::{
10 object,
11 objective_c_runtime::{
12 macros::interface_impl,
13 traits::{FromId, PNSObject},
14 INSValue,
15 },
16 utils::to_bool,
17};
18
19use super::{Int, NSCoder, NSComparisonResult, NSDecimal, NSLocale, NSString, UInt};
20
21object! {
22 /// An object wrapper for primitive scalar numeric values.
23 unsafe pub struct NSNumber;
24}
25
26impl INSValue for NSNumber {}
27
28#[interface_impl(NSValue)]
29impl NSNumber {
30 /* Creating an NSNumber Object
31 */
32
33 /// Creates and returns an NSNumber object containing a given value, treating it as a BOOL.
34 ///
35 /// # Arguments
36 ///
37 /// * `value` - The value to store in the NSNumber object.
38 ///
39 /// # Returns
40 ///
41 /// Returns an `NSNumber` object containing the value.
42 #[method]
43 pub fn number_with_bool(value: bool) -> Self
44 where
45 Self: Sized + 'static + FromId,
46 {
47 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithBool: value]) }
48 }
49
50 /// Creates and returns an NSNumber object containing a given value, treating it as a signed char.
51 ///
52 /// # Arguments
53 ///
54 /// * `value` - The value to store in the NSNumber object.
55 ///
56 /// # Returns
57 ///
58 /// Returns an `NSNumber` object containing the value.
59 #[method]
60 pub fn number_with_char(value: c_schar) -> Self
61 where
62 Self: Sized + FromId,
63 {
64 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithChar: value]) }
65 }
66
67 /// Creates and returns an NSNumber object containing a given value, treating it a double.
68 ///
69 /// # Arguments
70 ///
71 /// * `value` - The value to store in the NSNumber object.
72 ///
73 /// # Returns
74 ///
75 /// Returns an `NSNumber` object containing the value.
76 #[method]
77 pub fn number_with_double(value: c_double) -> Self
78 where
79 Self: Sized + FromId,
80 {
81 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithDouble: value]) }
82 }
83
84 /// Creates and returns an NSNumber object containing a given value, treating it as a float.
85 ///
86 /// # Arguments
87 ///
88 /// * `value` - The value to store in the NSNumber object.
89 ///
90 /// # Returns
91 ///
92 /// Returns an `NSNumber` object containing the value.
93 #[method]
94 pub fn number_with_float(value: c_float) -> Self
95 where
96 Self: Sized + FromId,
97 {
98 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithFloat: value]) }
99 }
100
101 /// Creates and returns an NSNumber object containing a given value, treating it as a signed int.
102 ///
103 /// # Arguments
104 ///
105 /// * `value` - The value to store in the NSNumber object.
106 ///
107 /// # Returns
108 ///
109 /// Returns an `NSNumber` object containing the value.
110 #[method]
111 pub fn number_with_int(value: c_int) -> Self
112 where
113 Self: Sized + FromId,
114 {
115 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithInt: value]) }
116 }
117
118 /// Creates and returns an NSNumber object containing a given value, treating it as an NSInteger.
119 ///
120 /// # Arguments
121 ///
122 /// * `value` - The value to store in the NSNumber object.
123 ///
124 /// # Returns
125 ///
126 /// Returns an `NSNumber` object containing the value.
127 #[method]
128 pub fn number_with_integer(value: Int) -> Self
129 where
130 Self: Sized + FromId,
131 {
132 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithInteger: value]) }
133 }
134
135 /// Creates and returns an NSNumber object containing a given value, treating it as a signed long.
136 ///
137 /// # Arguments
138 ///
139 /// * `value` - The value to store in the NSNumber object.
140 ///
141 /// # Returns
142 ///
143 /// Returns an `NSNumber` object containing the value.
144 #[method]
145 pub fn number_with_long(value: c_long) -> Self
146 where
147 Self: Sized + FromId,
148 {
149 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithLong: value]) }
150 }
151
152 /// Creates and returns an NSNumber object containing a given value, treating it as a signed long long.
153 ///
154 /// # Arguments
155 ///
156 /// * `value` - The value to store in the NSNumber object.
157 ///
158 /// # Returns
159 ///
160 /// Returns an `NSNumber` object containing the value.
161 #[method]
162 pub fn number_with_long_long(value: c_longlong) -> Self
163 where
164 Self: Sized + FromId,
165 {
166 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithLongLong: value]) }
167 }
168 /// Creates and returns an NSNumber object containing value, treating it as a signed short.
169 ///
170 /// # Arguments
171 ///
172 /// * `value` - The value to store in the NSNumber object.
173 ///
174 /// # Returns
175 ///
176 /// Returns an `NSNumber` object containing the value.
177 #[method]
178 pub fn number_with_short(value: c_short) -> Self
179 where
180 Self: Sized + FromId,
181 {
182 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithShort: value]) }
183 }
184
185 /// Creates and returns an NSNumber object containing a given value, treating it as an unsigned char.
186 ///
187 /// # Arguments
188 ///
189 /// * `value` - The value to store in the NSNumber object.
190 ///
191 /// # Returns
192 ///
193 /// Returns an `NSNumber` object containing the value.
194 #[method]
195 pub fn number_with_unsigned_char(value: c_uchar) -> Self
196 where
197 Self: Sized + FromId,
198 {
199 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithUnsignedChar: value]) }
200 }
201
202 /// Creates and returns an NSNumber object containing a given value, treating it as an unsigned int.
203 ///
204 /// # Arguments
205 ///
206 /// * `value` - The value to store in the NSNumber object.
207 ///
208 /// # Returns
209 ///
210 /// Returns an `NSNumber` object containing the value.
211 #[method]
212 pub fn number_with_unsigned_int(value: c_uint) -> Self
213 where
214 Self: Sized + FromId,
215 {
216 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithUnsignedInt: value]) }
217 }
218
219 /// Creates and returns an NSNumber object containing a given value, treating it as an NSUInteger.
220 ///
221 /// # Arguments
222 ///
223 /// * `value` - The value to store in the NSNumber object.
224 ///
225 /// # Returns
226 ///
227 /// Returns an `NSNumber` object containing the value.
228 #[method]
229 pub fn number_with_unsigned_integer(value: UInt) -> Self
230 where
231 Self: Sized + FromId,
232 {
233 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithUnsignedInteger: value]) }
234 }
235
236 /// Creates and returns an NSNumber object containing a given value, treating it as an unsigned long.
237 ///
238 /// # Arguments
239 ///
240 /// * `value` - The value to store in the NSNumber object.
241 ///
242 /// # Returns
243 ///
244 /// Returns an `NSNumber` object containing the value.
245 #[method]
246 pub fn number_with_unsigned_long(value: c_ulong) -> Self
247 where
248 Self: Sized + FromId,
249 {
250 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithUnsignedLong: value]) }
251 }
252
253 /// Creates and returns an NSNumber object containing a given value, treating it as an unsigned long long.
254 ///
255 /// # Arguments
256 ///
257 /// * `value` - The value to store in the NSNumber object.
258 ///
259 /// # Returns
260 ///
261 /// Returns an `NSNumber` object containing the value.
262 #[method]
263 pub fn number_with_unsigned_long_long(value: c_ulonglong) -> Self
264 where
265 Self: Sized + FromId,
266 {
267 unsafe {
268 Self::from_id(msg_send![
269 Self::m_class(),
270 numberWithUnsignedLongLong: value
271 ])
272 }
273 }
274
275 /// Creates and returns an NSNumber object containing a given value, treating it as an unsigned short.
276 ///
277 /// # Arguments
278 ///
279 /// * `value` - The value to store in the NSNumber object.
280 ///
281 /// # Returns
282 ///
283 /// Returns an `NSNumber` object containing the value.
284 #[method]
285 pub fn number_with_unsigned_short(value: c_ushort) -> Self
286 where
287 Self: Sized + FromId,
288 {
289 unsafe { Self::from_id(msg_send![Self::m_class(), numberWithUnsignedShort: value]) }
290 }
291
292 /* Initializing an NSNumber Object
293 */
294
295 /// Returns an NSNumber object initialized to contain a given value, treated as a BOOL.
296 ///
297 /// # Arguments
298 ///
299 /// * `value` - The value to store in the NSNumber object.
300 #[method]
301 pub fn init_with_bool(&mut self, value: bool) -> Self
302 where
303 Self: Sized + FromId,
304 {
305 unsafe { Self::from_id(msg_send![self.m_self(), initWithBool: value]) }
306 }
307
308 /// Returns an NSNumber object initialized to contain a given value, treated as a signed char.
309 ///
310 /// # Arguments
311 ///
312 /// * `value` - The value to store in the NSNumber object.
313 ///
314 /// # Returns
315 ///
316 /// Returns an `NSNumber` object containing the value.
317 #[method]
318 pub fn init_with_char(&mut self, value: c_schar) -> Self
319 where
320 Self: Sized + FromId,
321 {
322 unsafe { Self::from_id(msg_send![self.m_self(), initWithChar: value]) }
323 }
324
325 /// Returns an NSNumber object initialized to contain value, treated as a double.
326 ///
327 /// # Arguments
328 ///
329 /// * `value` - The value to store in the NSNumber object.
330 ///
331 /// # Returns
332 ///
333 /// Returns an `NSNumber` object containing the value.
334 #[method]
335 pub fn init_with_double(&mut self, value: c_double) -> Self
336 where
337 Self: Sized + FromId,
338 {
339 unsafe { Self::from_id(msg_send![self.m_self(), initWithDouble: value]) }
340 }
341
342 /// Returns an NSNumber object initialized to contain a given value, treated as a float.
343 ///
344 /// # Arguments
345 ///
346 /// * `value` - The value to store in the NSNumber object.
347 ///
348 /// # Returns
349 ///
350 /// Returns an `NSNumber` object containing the value.
351 #[method]
352 pub fn init_with_float(&mut self, value: c_float) -> Self
353 where
354 Self: Sized + FromId,
355 {
356 unsafe { Self::from_id(msg_send![self.m_self(), initWithFloat: value]) }
357 }
358
359 /// Returns an NSNumber object initialized to contain a given value, treated as a signed int.
360 ///
361 /// # Arguments
362 ///
363 /// * `value` - The value to store in the NSNumber object.
364 ///
365 /// # Returns
366 ///
367 /// Returns an `NSNumber` object containing the value.
368 #[method]
369 pub fn init_with_int(&mut self, value: c_int) -> Self
370 where
371 Self: Sized + FromId,
372 {
373 unsafe { Self::from_id(msg_send![self.m_self(), initWithInt: value]) }
374 }
375
376 /// Returns an NSNumber object initialized to contain a given value, treated as an NSInteger.
377 ///
378 /// # Arguments
379 ///
380 /// * `value` - The value to store in the NSNumber object.
381 ///
382 /// # Returns
383 ///
384 /// Returns an `NSNumber` object containing the value.
385 #[method]
386 pub fn init_with_integer(&mut self, value: Int) -> Self
387 where
388 Self: Sized + FromId,
389 {
390 unsafe { Self::from_id(msg_send![self.m_self(), initWithInteger: value]) }
391 }
392
393 /// Returns an NSNumber object initialized to contain a given value, treated as a signed long.
394 ///
395 /// # Arguments
396 ///
397 /// * `value` - The value to store in the NSNumber object.
398 ///
399 /// # Returns
400 ///
401 /// Returns an `NSNumber` object containing the value.
402 #[method]
403 pub fn init_with_long(&mut self, value: c_long) -> Self
404 where
405 Self: Sized + FromId,
406 {
407 unsafe { Self::from_id(msg_send![self.m_self(), initWithLong: value]) }
408 }
409
410 /// Returns an NSNumber object initialized to contain value, treated as a signed long long.
411 ///
412 /// # Arguments
413 ///
414 /// * `value` - The value to store in the NSNumber object.
415 ///
416 /// # Returns
417 ///
418 /// Returns an `NSNumber` object containing the value.
419 #[method]
420 pub fn init_with_long_long(&mut self, value: c_longlong) -> Self
421 where
422 Self: Sized + FromId,
423 {
424 unsafe { Self::from_id(msg_send![self.m_self(), initWithLongLong: value]) }
425 }
426
427 /// Returns an NSNumber object initialized to contain a given value, treated as a signed short.
428 ///
429 /// # Arguments
430 ///
431 /// * `value` - The value to store in the NSNumber object.
432 ///
433 /// # Returns
434 ///
435 /// Returns an `NSNumber` object containing the value.
436 #[method]
437 pub fn init_with_short(&mut self, value: c_short) -> Self
438 where
439 Self: Sized + FromId,
440 {
441 unsafe { Self::from_id(msg_send![self.m_self(), initWithShort: value]) }
442 }
443
444 /// Returns an NSNumber object initialized to contain a given value, treated as an unsigned char.
445 ///
446 /// # Arguments
447 ///
448 /// * `value` - The value to store in the NSNumber object.
449 ///
450 /// # Returns
451 ///
452 /// Returns an `NSNumber` object containing the value.
453 #[method]
454 pub fn init_with_unsigned_char(&mut self, value: c_uchar) -> Self
455 where
456 Self: Sized + FromId,
457 {
458 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedChar: value]) }
459 }
460
461 /// Returns an NSNumber object initialized to contain a given value, treated as an unsigned int.
462 ///
463 /// # Arguments
464 ///
465 /// * `value` - The value to store in the NSNumber object.
466 ///
467 /// # Returns
468 ///
469 /// Returns an `NSNumber` object containing the value.
470 #[method]
471 pub fn init_with_unsigned_int(&mut self, value: c_uint) -> Self
472 where
473 Self: Sized + FromId,
474 {
475 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedInt: value]) }
476 }
477
478 /// Returns an NSNumber object initialized to contain a given value, treated as an NSUInteger.
479 ///
480 /// # Arguments
481 ///
482 /// * `value` - The value to store in the NSNumber object.
483 ///
484 /// # Returns
485 ///
486 /// Returns an `NSNumber` object containing the value.
487 #[method]
488 pub fn init_with_unsigned_integer(&mut self, value: c_uint) -> Self
489 where
490 Self: Sized + FromId,
491 {
492 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedInteger: value]) }
493 }
494
495 /// Returns an NSNumber object initialized to contain a given value, treated as an unsigned long.
496 ///
497 /// # Arguments
498 ///
499 /// * `value` - The value to store in the NSNumber object.
500 ///
501 /// # Returns
502 ///
503 /// Returns an `NSNumber` object containing the value.
504 #[method]
505 pub fn init_with_unsigned_long(&mut self, value: c_ulong) -> Self
506 where
507 Self: Sized + FromId,
508 {
509 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedLong: value]) }
510 }
511
512 /// Returns an NSNumber object initialized to contain a given value, treated as an unsigned long long.
513 ///
514 /// # Arguments
515 ///
516 /// * `value` - The value to store in the NSNumber object.
517 ///
518 /// # Returns
519 ///
520 /// Returns an `NSNumber` object containing the value.
521 #[method]
522 pub fn init_with_unsigned_long_long(&mut self, value: c_ulonglong) -> Self
523 where
524 Self: Sized + FromId,
525 {
526 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedLongLong: value]) }
527 }
528
529 /// Returns an NSNumber object initialized to contain a given value, treated as an unsigned short.
530 ///
531 /// # Arguments
532 ///
533 /// * `value` - The value to store in the NSNumber object.
534 ///
535 /// # Returns
536 ///
537 /// Returns an `NSNumber` object containing the value.
538 #[method]
539 pub fn init_with_unsigned_short(&mut self, value: c_ushort) -> Self
540 where
541 Self: Sized + FromId,
542 {
543 unsafe { Self::from_id(msg_send![self.m_self(), initWithUnsignedShort: value]) }
544 }
545
546 /* Accessing Numeric Values
547 */
548
549 /// The number object's value expressed as a Boolean value.
550 #[property]
551 pub fn bool_value(&self) -> bool {
552 unsafe { to_bool(msg_send![self.m_self(), boolValue]) }
553 }
554
555 /// The number object's value expressed as a char.
556 #[property]
557 pub fn char_value(&self) -> c_schar {
558 unsafe { msg_send![self.m_self(), charValue] }
559 }
560
561 /// The number object's value expressed as an NSDecimal structure.
562 #[property]
563 pub fn decimal_value(&self) -> NSDecimal {
564 unsafe { NSDecimal::from_id(msg_send![self.m_self(), decimalValue]) }
565 }
566
567 /// The number object's value expressed as a double, converted as necessary.
568 #[property]
569 pub fn double_value(&self) -> c_double {
570 unsafe { msg_send![self.m_self(), doubleValue] }
571 }
572
573 /// The number object's value expressed as a float, converted as necessary.
574 #[property]
575 pub fn float_value(&self) -> c_float {
576 unsafe { msg_send![self.m_self(), floatValue] }
577 }
578
579 /// The number object's value expressed as an int, converted as necessary.
580 #[property]
581 pub fn int_value(&self) -> c_int {
582 unsafe { msg_send![self.m_self(), intValue] }
583 }
584
585 /// The number object's value expressed as an NSInteger object, converted as necessary.
586 #[property]
587 pub fn integer_value(&self) -> Int {
588 unsafe { msg_send![self.m_self(), integerValue] }
589 }
590
591 /// The number object’s value expressed as a long long, converted as necessary.
592 #[property]
593 pub fn long_long_value(&self) -> c_longlong {
594 unsafe { msg_send![self.m_self(), longLongValue] }
595 }
596
597 /// The number object’s value expressed as a long, converted as necessary.
598 #[property]
599 pub fn long_value(&self) -> c_long {
600 unsafe { msg_send![self.m_self(), longValue] }
601 }
602
603 /// The number object's value expressed as a short, converted as necessary.
604 #[property]
605 pub fn short_value(&self) -> c_short {
606 unsafe { msg_send![self.m_self(), shortValue] }
607 }
608
609 /// The number object's value expressed as an unsigned char, converted as necessary.
610 #[property]
611 pub fn unsigned_char_value(&self) -> c_uchar {
612 unsafe { msg_send![self.m_self(), unsignedCharValue] }
613 }
614
615 /// The number object's value expressed as an NSUInteger object, converted as necessary.
616 #[property]
617 pub fn unsigned_integer_value(&self) -> UInt {
618 unsafe { msg_send![self.m_self(), unsignedIntegerValue] }
619 }
620
621 /// The number object's value expressed as an unsigned int, converted as necessary.
622 #[property]
623 pub fn unsigned_int_value(&self) -> c_uint {
624 unsafe { msg_send![self.m_self(), unsignedIntValue] }
625 }
626
627 /// The number object’s value expressed as an unsigned long long, converted as necessary.
628 #[property]
629 pub fn unsigned_long_long_value(&self) -> c_ulonglong {
630 unsafe { msg_send![self.m_self(), unsignedLongLongValue] }
631 }
632
633 /// The number object's value expressed as an unsigned long, converted as necessary.
634 #[property]
635 pub fn unsigned_long_value(&self) -> c_ulong {
636 unsafe { msg_send![self.m_self(), unsignedLongValue] }
637 }
638
639 /// The number object's value expressed as an unsigned short, converted as necessary.
640 #[property]
641 pub fn unsigned_short_value(&self) -> c_ushort {
642 unsafe { msg_send![self.m_self(), unsignedShortValue] }
643 }
644
645 /* Retrieving String Representations
646 */
647
648 /// Returns a string that represents the contents of the number object for a given locale.
649 ///
650 /// # Arguments
651 ///
652 /// * `locale` - The locale to use to format the number.
653 ///
654 /// # Returns
655 ///
656 /// A string that represents the contents of the number object formatted using the locale information in `locale`.
657 #[method]
658 pub fn description_with_locale(&self, locale: &NSLocale) -> NSString {
659 unsafe {
660 NSString::from_id(msg_send![self.m_self(), descriptionWithLocale: locale.m_self()])
661 }
662 }
663
664 /// The number object's value expressed as a human-readable string.
665 #[property]
666 pub fn string_value(&self) -> NSString {
667 unsafe { NSString::from_id(msg_send![self.m_self(), stringValue]) }
668 }
669
670 /* Comparing NSNumber Objects
671 */
672
673 /// Returns an NSComparisonResult value that indicates whether the number object’s value is greater than, equal to, or less than a given number.
674 ///
675 /// # Arguments
676 ///
677 /// * `other` - The number to compare to the number object’s value.
678 #[method]
679 pub fn compare(&self, other: &Self) -> NSComparisonResult {
680 unsafe { msg_send![self.m_self(), compare: other.m_self()] }
681 }
682
683 /// Returns a Boolean value that indicates whether the number object’s value and a given number are equal.
684 ///
685 /// # Arguments
686 ///
687 /// * `other` - The number to compare to the number object’s value.
688 #[method]
689 pub fn is_equal_to_number(&self, other: &Self) -> bool {
690 unsafe { to_bool(msg_send![self.m_self(), isEqualToNumber: other.m_self()]) }
691 }
692
693 /* Accessing Type Information
694 */
695
696 /// Returns a C string containing the Objective-C type of the data contained in the number object.
697 ///
698 /// # Return Value
699 /// A C string containing the Objective-C type of the data contained in the number object,
700 /// as encoded by the @encode() compiler directive.
701 #[method]
702 pub fn objc_type(&self) -> *const char {
703 unsafe { msg_send![self.m_self(), objCType] }
704 }
705
706 /* Initializers */
707
708 ///
709 #[method]
710 fn init_with_coder(&mut self, coder: &NSCoder) -> Self
711 where
712 Self: Sized + FromId,
713 {
714 unsafe { Self::from_id(msg_send![self.m_self(), initWithCoder: coder.m_self()]) }
715 }
716}
717
718impl Default for NSNumber {
719 fn default() -> Self {
720 Self::m_new()
721 }
722}
723
724impl PartialEq for NSNumber {
725 fn eq(&self, other: &Self) -> bool {
726 self.is_equal_to_number(other)
727 }
728}
729
730impl Add for NSNumber {
731 type Output = Self;
732
733 fn add(self, other: Self) -> Self {
734 (self.integer_value() + other.integer_value()).into()
735 }
736}
737
738impl<T> FromIterator<T> for NSNumber
739where
740 T: Into<NSNumber>,
741{
742 fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
743 let mut sum = NSNumber::from(0);
744 for item in iter {
745 sum = sum + item.into();
746 }
747 sum
748 }
749}
750
751impl From<c_float> for NSNumber {
752 fn from(value: c_float) -> Self {
753 NSNumber::number_with_float(value)
754 }
755}
756
757impl From<c_double> for NSNumber {
758 fn from(value: c_double) -> Self {
759 NSNumber::number_with_double(value)
760 }
761}
762
763impl From<c_schar> for NSNumber {
764 fn from(value: c_schar) -> Self {
765 NSNumber::number_with_char(value)
766 }
767}
768
769impl From<c_uchar> for NSNumber {
770 fn from(value: c_uchar) -> Self {
771 NSNumber::number_with_unsigned_char(value)
772 }
773}
774
775impl From<c_short> for NSNumber {
776 fn from(value: c_short) -> Self {
777 NSNumber::number_with_short(value)
778 }
779}
780
781impl From<c_ushort> for NSNumber {
782 fn from(value: c_ushort) -> Self {
783 NSNumber::number_with_unsigned_short(value)
784 }
785}
786
787impl From<c_int> for NSNumber {
788 fn from(value: c_int) -> Self {
789 NSNumber::number_with_int(value)
790 }
791}
792
793impl From<c_uint> for NSNumber {
794 fn from(value: c_uint) -> Self {
795 NSNumber::number_with_unsigned_int(value)
796 }
797}
798
799impl From<c_long> for NSNumber {
800 fn from(value: c_long) -> Self {
801 NSNumber::number_with_long(value)
802 }
803}
804
805impl From<c_ulong> for NSNumber {
806 fn from(value: c_ulong) -> Self {
807 NSNumber::number_with_unsigned_long(value)
808 }
809}