From 5816505c94fb5521a9bc557713a09eb124845d68 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 20 Sep 2023 15:28:44 +0200 Subject: [PATCH] Rename MethodImplementation's associated types --- crates/objc2/CHANGELOG.md | 2 ++ crates/objc2/src/declare/mod.rs | 10 +++++----- .../objc2/src/runtime/method_implementation.rs | 16 +++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index ed3c0c89b..02818835b 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -44,6 +44,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Relaxed the requirements for receivers in `MethodImplementation`; now, anything that implements `MessageReceiver` can be used as the receiver of a method. +* **BREAKING**: Renamed the associated types `Ret` and `Args` on + `MethodImplementation` to `Return` and `Arguments`. ### Deprecated * Soft deprecated using `msg_send!` without a comma between arguments (i.e. diff --git a/crates/objc2/src/declare/mod.rs b/crates/objc2/src/declare/mod.rs index ab6324266..a58b8908a 100644 --- a/crates/objc2/src/declare/mod.rs +++ b/crates/objc2/src/declare/mod.rs @@ -241,7 +241,7 @@ impl ClassBuilder { /// `-release` used by ARC, will not be present otherwise. pub fn root(name: &str, intitialize_fn: F) -> Option where - F: MethodImplementation, + F: MethodImplementation, { Self::with_superclass(name, None).map(|mut this| { unsafe { this.add_class_method(sel!(initialize), intitialize_fn) }; @@ -274,8 +274,8 @@ impl ClassBuilder { unsafe { self.add_method_inner( sel, - F::Args::ENCODINGS, - &F::Ret::ENCODING_RETURN, + F::Arguments::ENCODINGS, + &F::Return::ENCODING_RETURN, func.__imp(), ) } @@ -338,8 +338,8 @@ impl ClassBuilder { unsafe { self.add_class_method_inner( sel, - F::Args::ENCODINGS, - &F::Ret::ENCODING_RETURN, + F::Arguments::ENCODINGS, + &F::Return::ENCODING_RETURN, func.__imp(), ) } diff --git a/crates/objc2/src/runtime/method_implementation.rs b/crates/objc2/src/runtime/method_implementation.rs index 73e2dd1b6..1c80ba24a 100644 --- a/crates/objc2/src/runtime/method_implementation.rs +++ b/crates/objc2/src/runtime/method_implementation.rs @@ -19,10 +19,12 @@ mod private { pub trait MethodImplementation: private::Sealed + Sized { /// The callee type of the method. type Callee: ?Sized + RefEncode; - /// The return type of the method. - type Ret: EncodeReturn; + /// The argument types of the method. - type Args: EncodeArguments; + type Arguments: EncodeArguments; + + /// The return type of the method. + type Return: EncodeReturn; #[doc(hidden)] fn __imp(self) -> Imp; @@ -44,8 +46,8 @@ macro_rules! method_impl_inner { $($t: EncodeArgument,)* { type Callee = T::__Inner; - type Ret = R; - type Args = ($($t,)*); + type Arguments = ($($t,)*); + type Return = R; fn __imp(self) -> Imp { // SAFETY: Transmuting to an `unsafe` function pointer @@ -66,8 +68,8 @@ macro_rules! method_impl_inner { $($t: EncodeArgument,)* { type Callee = T; - type Ret = IdReturnValue; - type Args = ($($t,)*); + type Arguments = ($($t,)*); + type Return = IdReturnValue; fn __imp(self) -> Imp { // SAFETY: `Allocated` is the same as `NonNull`, except