File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,21 @@ use core::fmt;
3
3
4
4
/// The Objective-C `BOOL` type.
5
5
///
6
- /// To convert an Objective-C `BOOL` into a Rust [`bool`], call the one of the
6
+ /// Usually, you would convert this into a Rust [`bool`] with the
7
7
/// [`Bool::is_false`] or [`Bool::is_true`] methods.
8
8
///
9
9
/// This is FFI-safe and can be used in directly with
10
10
/// [`msg_send!`][`crate::msg_send`].
11
+ ///
12
+ /// # Example
13
+ ///
14
+ /// ```no_run
15
+ /// use objc2::{class, msg_send};
16
+ /// use objc2::runtime::{Object, Bool};
17
+ /// let ns_value: *mut Object = unsafe { msg_send![class!(NSValue), initWithBool: Bool::YES] };
18
+ /// let rtn: Bool = unsafe { msg_send![ns_value, boolValue] };
19
+ /// assert!(rtn.is_true());
20
+ /// ```
11
21
#[ repr( transparent) ]
12
22
// TODO: Might have to implement some of these manually, in case someone puts
13
23
// something that is not 0 or 1 into the Bool?
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ impl Class {
293
293
294
294
/// Checks whether this class conforms to the specified protocol.
295
295
pub fn conforms_to ( & self , proto : & Protocol ) -> bool {
296
- unsafe { Bool :: from_raw ( class_conformsToProtocol ( self . as_ptr ( ) , proto. as_ptr ( ) ) ) . into ( ) }
296
+ unsafe { Bool :: from_raw ( class_conformsToProtocol ( self . as_ptr ( ) , proto. as_ptr ( ) ) ) . is_true ( ) }
297
297
}
298
298
299
299
/// Get a list of the protocols to which this class conforms.
@@ -368,7 +368,9 @@ impl Protocol {
368
368
369
369
/// Checks whether this protocol conforms to the specified protocol.
370
370
pub fn conforms_to ( & self , proto : & Protocol ) -> bool {
371
- unsafe { Bool :: from_raw ( protocol_conformsToProtocol ( self . as_ptr ( ) , proto. as_ptr ( ) ) ) . into ( ) }
371
+ unsafe {
372
+ Bool :: from_raw ( protocol_conformsToProtocol ( self . as_ptr ( ) , proto. as_ptr ( ) ) ) . is_true ( )
373
+ }
372
374
}
373
375
374
376
/// Returns the name of self.
You can’t perform that action at this time.
0 commit comments