@@ -10,7 +10,7 @@ The following example demonstrates declaring a class named `MyNumber` that has
1010one ivar, a `u32` named `_number` and a `number` method that returns it:
1111
1212``` no_run
13- # #[macro_use] extern crate objc;
13+ # use objc::class ;
1414# use objc::declare::ClassDecl;
1515# use objc::runtime::{Class, Object, Sel};
1616# fn main() {
@@ -91,7 +91,7 @@ fn count_args(sel: Sel) -> usize {
9191 sel. name ( ) . chars ( ) . filter ( |& c| c == ':' ) . count ( )
9292}
9393
94- fn method_type_encoding ( ret : & Encoding , args : & [ Encoding ] ) -> CString {
94+ fn method_type_encoding ( ret : & Encoding < ' _ > , args : & [ Encoding < ' _ > ] ) -> CString {
9595 // First two arguments are always self and the selector
9696 let mut types = format ! ( "{}{}{}" , ret, <* mut Object >:: ENCODING , Sel :: ENCODING ) ;
9797 for enc in args {
@@ -123,7 +123,7 @@ impl ClassDecl {
123123 if cls. is_null ( ) {
124124 None
125125 } else {
126- Some ( ClassDecl { cls : cls } )
126+ Some ( ClassDecl { cls } )
127127 }
128128 }
129129
@@ -159,8 +159,11 @@ impl ClassDecl {
159159 /// Adds a method with the given name and implementation to self.
160160 /// Panics if the method wasn't sucessfully added
161161 /// or if the selector and function take different numbers of arguments.
162- /// Unsafe because the caller must ensure that the types match those that
163- /// are expected when the method is invoked from Objective-C.
162+ ///
163+ /// # Safety
164+ ///
165+ /// The caller must ensure that the types match those that are expected
166+ /// when the method is invoked from Objective-C.
164167 pub unsafe fn add_method < F > ( & mut self , sel : Sel , func : F )
165168 where
166169 F : MethodImplementation < Callee = Object > ,
@@ -182,8 +185,11 @@ impl ClassDecl {
182185 /// Adds a class method with the given name and implementation to self.
183186 /// Panics if the method wasn't sucessfully added
184187 /// or if the selector and function take different numbers of arguments.
185- /// Unsafe because the caller must ensure that the types match those that
186- /// are expected when the method is invoked from Objective-C.
188+ ///
189+ /// # Safety
190+ ///
191+ /// The caller must ensure that the types match those that are expected
192+ /// when the method is invoked from Objective-C.
187193 pub unsafe fn add_class_method < F > ( & mut self , sel : Sel , func : F )
188194 where
189195 F : MethodImplementation < Callee = Class > ,
@@ -262,7 +268,7 @@ impl ProtocolDecl {
262268 if proto. is_null ( ) {
263269 None
264270 } else {
265- Some ( ProtocolDecl { proto : proto } )
271+ Some ( ProtocolDecl { proto } )
266272 }
267273 }
268274
0 commit comments