Skip to content

Commit 74bebe6

Browse files
committed
Add optional Send requirement to internall callbacks
1 parent 9891e86 commit 74bebe6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/types.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ unsafe impl Send for LightUserData {}
4646
#[cfg(feature = "send")]
4747
unsafe impl Sync for LightUserData {}
4848

49+
#[cfg(feature = "send")]
50+
pub(crate) type Callback = Box<dyn Fn(&RawLua, c_int) -> Result<c_int> + Send + 'static>;
51+
52+
#[cfg(not(feature = "send"))]
4953
pub(crate) type Callback = Box<dyn Fn(&RawLua, c_int) -> Result<c_int> + 'static>;
5054

5155
pub(crate) struct Upvalue<T> {
@@ -55,7 +59,11 @@ pub(crate) struct Upvalue<T> {
5559

5660
pub(crate) type CallbackUpvalue = Upvalue<Callback>;
5761

58-
#[cfg(feature = "async")]
62+
#[cfg(all(feature = "async", feature = "send"))]
63+
pub(crate) type AsyncCallback =
64+
Box<dyn for<'a> Fn(&'a RawLua, c_int) -> BoxFuture<'a, Result<c_int>> + Send + 'static>;
65+
66+
#[cfg(all(feature = "async", not(feature = "send")))]
5967
pub(crate) type AsyncCallback =
6068
Box<dyn for<'a> Fn(&'a RawLua, c_int) -> BoxFuture<'a, Result<c_int>> + 'static>;
6169

0 commit comments

Comments
 (0)