Skip to content

Commit cb29636

Browse files
committed
Allow msg_send_id![obj, init] to non-option wrapped Id
1 parent 77d8db4 commit cb29636

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

objc2/src/rc/alloc.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ impl<T: ?Sized + Message, O: Ownership> __MsgSendId<Option<Id<Allocated<T>, O>>,
9595
}
9696
}
9797

98+
impl<T: ?Sized + Message, O: Ownership> __MsgSendId<Id<Allocated<T>, O>, Option<Id<T, O>>>
99+
for __Assert<false, true, true>
100+
{
101+
#[inline(always)]
102+
unsafe fn __send_message_id<A: MessageArguments>(
103+
obj: Id<Allocated<T>, O>,
104+
sel: Sel,
105+
args: A,
106+
) -> Result<Option<Id<T, O>>, MessageError> {
107+
let ptr = Id::consume_as_ptr(ManuallyDrop::new(obj));
108+
unsafe { MessageReceiver::send_message(ptr, sel, args).map(|r| Id::new(r)) }
109+
}
110+
}
111+
98112
impl<T: ?Sized + Message, O: Ownership>
99113
__MsgSuperSendId<Id<Allocated<T>, O>, Option<Id<Allocated<T>, O>>>
100114
for __Assert<false, true, true>

0 commit comments

Comments
 (0)