Skip to content

Commit 14a4fd2

Browse files
committed
Small documentation fixes
1 parent 03c171c commit 14a4fd2

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

objc2/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
//!
108108
//! To use this functionality, enable the `"verify_message"` cargo feature
109109
//! while debugging. With this feature enabled, encodings are checked every
110-
//! time your send a message, and the message send will panic if they are not
110+
//! time you send a message, and the message send will panic if they are not
111111
//! equivalent.
112112
//!
113113
//! To take the example above, if we changed the `hash` method's return type

objc2/src/macros.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ macro_rules! sel {
7171
/// ```
7272
///
7373
/// This way we are clearly communicating to Rust that: The method
74-
/// `doSomething:` works on shared references to an object. It takes a C-style
75-
/// signed integer, and returns a pointer to what is probably a C-compatible
76-
/// string. Now it's much, _much_ easier to make a safe abstraction around
77-
/// this!
74+
/// `doSomething:` works with a shared reference to the object. It takes a
75+
/// C-style signed integer, and returns a pointer to what is probably a
76+
/// C-compatible string. Now it's much, _much_ easier to make a safe
77+
/// abstraction around this!
7878
///
7979
/// There exists two variants of this macro, [`msg_send_bool!`] and
8080
/// [`msg_send_id!`], which can help with upholding certain requirements of
@@ -94,9 +94,12 @@ macro_rules! sel {
9494
///
9595
/// All arguments, and the return type, must implement [`Encode`].
9696
///
97-
/// This translates into a call to [`sel!`], and afterwards a fully qualified
98-
/// call to [`MessageReceiver::send_message`]. Note that this means that
99-
/// auto-dereferencing of the receiver is not supported.
97+
/// This macro translates into a call to [`sel!`], and afterwards a fully
98+
/// qualified call to [`MessageReceiver::send_message`]. Note that this means
99+
/// that auto-dereferencing of the receiver is not supported, and that the
100+
/// receiver is consumed. You may encounter a little trouble with `&mut`
101+
/// references, try refactoring into a separate method or reborrowing the
102+
/// reference.
100103
///
101104
/// Variadic arguments are currently not supported.
102105
///
@@ -127,10 +130,9 @@ macro_rules! sel {
127130
/// 1. The selector corresponds to a valid method that is available on the
128131
/// receiver.
129132
///
130-
/// 2. The argument types must match what the receiver excepts for this
131-
/// selector.
133+
/// 2. The argument types match what the receiver excepts for this selector.
132134
///
133-
/// 3. The return type must match what the receiver returns for this selector.
135+
/// 3. The return type match what the receiver returns for this selector.
134136
///
135137
/// 4. The call must not violate Rust's mutability rules, for example if
136138
/// passing an `&T`, the Objective-C method must not mutate the variable
@@ -166,9 +168,9 @@ macro_rules! sel {
166168
/// # let obj: *mut Object = 0 as *mut Object;
167169
/// let description: *const Object = unsafe { msg_send![obj, description] };
168170
/// // Usually you'd use msg_send_id here ^
169-
/// let _: () = unsafe { msg_send![obj, setArg1: 1 arg2: 2] };
170-
/// // Or with an optional comma between arguments:
171-
/// let _: () = unsafe { msg_send![obj, setArg1: 1, arg2: 2] };
171+
/// let _: () = unsafe { msg_send![obj, setArg1: 1u32, arg2: 2i32] };
172+
/// let arg1: i32 = unsafe { msg_send![obj, getArg1] };
173+
/// let arg2: i32 = unsafe { msg_send![obj, getArg2] };
172174
/// ```
173175
#[macro_export]
174176
macro_rules! msg_send {
@@ -263,7 +265,7 @@ macro_rules! msg_send_bool {
263265
/// [`msg_send!`] for methods returning `id`, `NSObject*`, or similar object
264266
/// pointers.
265267
///
266-
/// Objective-C's object pointers have certain rules for when they should be
268+
/// Object pointers in Objective-C have certain rules for when they should be
267269
/// retained and released across function calls. This macro helps doing that,
268270
/// and returns an [`Option`] (letting you handle failures) containing an
269271
/// [`rc::Id`] with the object.
@@ -333,10 +335,9 @@ macro_rules! msg_send_bool {
333335
/// pools!
334336
///
335337
/// See [the clang documentation][arc-retainable] for the precise
336-
/// specification.
338+
/// specification of Objective-C's ownership rules.
337339
///
338340
/// This macro doesn't support super methods yet, see [#173].
339-
///
340341
/// The `retain`, `release` and `autorelease` selectors are not supported, use
341342
/// [`Id::retain`], [`Id::drop`] and [`Id::autorelease`] for that.
342343
///
@@ -402,7 +403,7 @@ macro_rules! msg_send_id {
402403
});
403404
}
404405

405-
/// Helper macro: To avoid exposing these in the docs for [`msg_send_id!`].
406+
/// Helper macro to avoid exposing these in the docs for [`msg_send_id!`].
406407
#[doc(hidden)]
407408
#[macro_export]
408409
macro_rules! __msg_send_id_helper {

objc2/src/rc/test_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl RcTestObject {
152152
}
153153

154154
pub(crate) fn new() -> Id<Self, Owned> {
155-
// Use msg_send! to test that; msg_send_id! is tested elsewhere!
155+
// Use msg_send! - msg_send_id! is tested elsewhere!
156156
unsafe { Id::new(msg_send![Self::class(), new]) }.unwrap()
157157
}
158158
}

0 commit comments

Comments
 (0)