Fix some invalid msg_send! usage#2138
Conversation
ArturKovacs
left a comment
There was a problem hiding this comment.
Thank you for making these improvements.
There is one thing that bugs me. The fact that we have to write
my_objc_bool != NOI know that it's necessary to compare against NO, but then we have a double negation for every single truthy check.
Here's an alternative:
trait BoolYeah {
/// This is true when `self` is not `NO`
///
/// Note that this different from
/// `self == YES`
/// because YES is the value 1 but
/// a BOOL may be any signed 8bit value
fn yeah(self) -> bool;
fn no(self) -> bool;
}
impl BoolYeah for objc::runtime::BOOL {
#[inline]
fn yeah(self) -> bool {
self != 0
}
#[inline]
fn no(self) -> bool {
self == 0
}
}So that we can write
if window_has_focus.yeah() {
It would be more clear to have |
|
Just to throw another option into the mix, what about |
|
Maybe just a conversion, e.g. |
|
In my fork of I intend to use that fork in |
|
Alright, I'm looking forward to moving to your fork of objc then. |
Thanks! Though intending to move to something else in the unknown future shouldn't be a blocker for adding |
Change a few types for more correct behaviour (e.g. using
boolmay be undefined behaviour, one should useBOOL).The only critical thing here is the stuff in
unmark_text(introduced in #2119), that part is certainly undefined behaviour, and will probably cause problems somewhere down the line.CHANGELOG.mdif knowledge of this change could be valuable to users