File tree Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,15 @@ extern "C" {}
1111// Only works on macOS >= 10.15 or iOS > 7.0
1212fn 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 ( ) } ;
Original file line number Diff line number Diff 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) ]
2021unsafe trait MsgSendFn : Encode {
2122 const MSG_SEND : Imp ;
2223 const MSG_SEND_SUPER : Imp ;
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ impl<T: Message> From<Id<T, Shared>> for WeakId<T> {
144144impl < 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments