Skip to content

Commit a291ca2

Browse files
committed
Appease clippy
1 parent 9122a83 commit a291ca2

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

objc2/examples/talk_to_me.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ extern "C" {}
1111
// Only works on macOS >= 10.15 or iOS > 7.0
1212
fn main() {
1313
let text = "Hello from Rust!";
14+
const UTF8_ENCODING: NSUInteger = 4;
1415

1516
let string: *const Object = unsafe { msg_send![class!(NSString), alloc] };
1617
let string = unsafe {
1718
msg_send![
1819
string,
1920
initWithBytes: text.as_ptr() as *const c_void,
2021
length: text.len(),
21-
encoding: 4 as NSUInteger, // UTF8_ENCODING on macOS / iOS
22+
encoding: UTF8_ENCODING,
2223
]
2324
};
2425
let string: Id<Object, Shared> = unsafe { Id::new(string).unwrap() };

objc2/src/message/apple/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod arch;
1717

1818
/// On the above architectures we can statically find the correct method to
1919
/// call from the return type, by looking at it's `Encode` implementation.
20+
#[allow(clippy::missing_safety_doc)]
2021
unsafe trait MsgSendFn: Encode {
2122
const MSG_SEND: Imp;
2223
const MSG_SEND_SUPER: Imp;

objc2/src/rc/weak_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<T: Message> From<Id<T, Shared>> for WeakId<T> {
144144
impl<T: Message> TryFrom<WeakId<T>> for Id<T, Shared> {
145145
type Error = ();
146146
fn try_from(weak: WeakId<T>) -> Result<Self, ()> {
147-
return weak.load().ok_or(());
147+
weak.load().ok_or(())
148148
}
149149
}
150150

objc2/src/runtime.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ impl Object {
532532
unsafe { &*ptr }
533533
}
534534

535-
/// Use [`ivar`](`Self::ivar`) instead.
535+
/// Use [`ivar`][`Self::ivar`] instead.
536+
///
537+
/// # Safety
538+
///
539+
/// Same as [`ivar`][`Self::ivar`].
536540
#[deprecated = "Use `Object::ivar` instead."]
537541
pub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T {
538542
// SAFETY: Upheld by caller
@@ -560,6 +564,10 @@ impl Object {
560564
}
561565

562566
/// Use [`ivar_mut`](`Self::ivar_mut`) instead.
567+
///
568+
/// # Safety
569+
///
570+
/// Same as [`ivar_mut`][`Self::ivar_mut`].
563571
#[deprecated = "Use `Object::ivar_mut` instead."]
564572
pub unsafe fn get_mut_ivar<T: Encode>(&mut self, name: &str) -> &mut T {
565573
// SAFETY: Upheld by caller

0 commit comments

Comments
 (0)