@@ -3,12 +3,16 @@ use core::fmt;
3
3
4
4
/// The Objective-C `BOOL` type.
5
5
///
6
- /// Usually, you would convert this into a Rust [`bool`] with the
7
- /// [`Bool::is_false`] or [`Bool::is_true`] methods.
6
+ /// This is a thin wrapper-type over [`objc2_sys::BOOL`]. It is intended that
7
+ /// you convert this into a Rust [`bool`] with the [`Bool::is_false`] or
8
+ /// [`Bool::is_true`] methods as soon as possible.
8
9
///
9
10
/// This is FFI-safe and can be used in directly with
10
11
/// [`msg_send!`][`crate::msg_send`].
11
12
///
13
+ /// Note that this is able to contain more states than `bool` on some
14
+ /// platforms, but these cases should not be relied on!
15
+ ///
12
16
/// # Example
13
17
///
14
18
/// ```no_run
@@ -19,9 +23,12 @@ use core::fmt;
19
23
/// assert!(rtn.is_true());
20
24
/// ```
21
25
#[ repr( transparent) ]
22
- // TODO: Might have to implement some of these manually, in case someone puts
23
- // something that is not 0 or 1 into the Bool?
24
- #[ derive( Copy , Clone , Default , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
26
+ // We don't implement comparison traits because they could be implemented with
27
+ // two slightly different semantics:
28
+ // - `self.is_true().cmp(other.is_true())`
29
+ // - `self.value.cmp(other.value)`
30
+ // And it is not immediately clear for users which one was chosen.
31
+ #[ derive( Copy , Clone , Default ) ]
25
32
pub struct Bool {
26
33
value : objc2_sys:: BOOL ,
27
34
}
@@ -48,7 +55,7 @@ impl Bool {
48
55
Self { value }
49
56
}
50
57
51
- /// Retrieves the inner `objc2_sys` boolean type, to be used in raw
58
+ /// Retrieves the inner [ `objc2_sys`] boolean type, to be used in raw
52
59
/// Objective-C APIs.
53
60
#[ inline]
54
61
pub const fn as_raw ( self ) -> objc2_sys:: BOOL {
0 commit comments