Skip to content

Commit ce2b0a9

Browse files
committed
Add public EncodeReturn, EncodeArgument and EncodeArguments
And make the two conversion traits ConvertReturn and ConvertArgument in a sense "more" private
1 parent c28f5ca commit ce2b0a9

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/block.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use core::marker::PhantomData;
22
use core::mem;
33

4-
use objc2::encode::__unstable::EncodeReturn;
5-
use objc2::encode::{Encode, Encoding, RefEncode};
4+
use objc2::encode::{EncodeArgument, EncodeReturn, Encoding, RefEncode};
65

76
use crate::ffi;
87

98
/// Types that may be used as the arguments of an Objective-C block.
109
///
1110
/// This is implemented for tuples of up to 12 arguments, where each argument
12-
/// implements [`Encode`].
11+
/// implements [`EncodeArgument`].
1312
///
1413
///
1514
/// # Safety
@@ -28,7 +27,7 @@ pub unsafe trait BlockArguments: Sized {
2827

2928
macro_rules! block_args_impl {
3029
($($a:ident: $t:ident),*) => (
31-
unsafe impl<$($t: Encode),*> BlockArguments for ($($t,)*) {
30+
unsafe impl<$($t: EncodeArgument),*> BlockArguments for ($($t,)*) {
3231
#[inline]
3332
unsafe fn __call_block<R: EncodeReturn>(
3433
invoke: unsafe extern "C" fn(),

src/concrete_block.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use core::ops::Deref;
55
use core::ptr;
66
use std::os::raw::c_ulong;
77

8-
use objc2::encode::__unstable::EncodeReturn;
9-
use objc2::encode::{Encode, Encoding, RefEncode};
8+
use objc2::encode::{EncodeArgument, EncodeReturn, Encoding, RefEncode};
109

1110
use crate::{ffi, Block, BlockArguments, RcBlock};
1211

@@ -17,7 +16,8 @@ mod private {
1716
/// Types that may be converted into a [`ConcreteBlock`].
1817
///
1918
/// This is implemented for [`Fn`] closures of up to 12 arguments, where each
20-
/// argument and the return type implements [`Encode`].
19+
/// argument implements [`EncodeArgument`] and the return type implements
20+
/// [`EncodeReturn`].
2121
///
2222
///
2323
/// # Safety
@@ -37,12 +37,12 @@ macro_rules! concrete_block_impl {
3737
concrete_block_impl!($f,);
3838
);
3939
($f:ident, $($a:ident : $t:ident),*) => (
40-
impl<$($t: Encode,)* R: EncodeReturn, X> private::Sealed<($($t,)*)> for X
40+
impl<$($t: EncodeArgument,)* R: EncodeReturn, X> private::Sealed<($($t,)*)> for X
4141
where
4242
X: Fn($($t,)*) -> R,
4343
{}
4444

45-
unsafe impl<$($t: Encode,)* R: EncodeReturn, X> IntoConcreteBlock<($($t,)*)> for X
45+
unsafe impl<$($t: EncodeArgument,)* R: EncodeReturn, X> IntoConcreteBlock<($($t,)*)> for X
4646
where
4747
X: Fn($($t,)*) -> R,
4848
{

src/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::ops::Deref;
55
use core::ptr;
66
use std::os::raw::c_ulong;
77

8-
use objc2::encode::__unstable::EncodeReturn;
8+
use objc2::encode::EncodeReturn;
99

1010
use super::{ffi, Block};
1111
use crate::BlockArguments;

0 commit comments

Comments
 (0)