Skip to content

Commit a86d6ab

Browse files
committed
Mark LightUserData as Send+Sync (send feature flag)
1 parent 2f8755d commit a86d6ab

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ pub(crate) enum SubtypeId {
4141
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
4242
pub struct LightUserData(pub *mut c_void);
4343

44+
#[cfg(feature = "send")]
45+
unsafe impl Send for LightUserData {}
46+
#[cfg(feature = "send")]
47+
unsafe impl Sync for LightUserData {}
48+
4449
pub(crate) type Callback<'a> = Box<dyn Fn(&'a RawLua, c_int) -> Result<c_int> + 'static>;
4550

4651
pub(crate) struct Upvalue<T> {

src/value.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,13 @@ pub trait FromLuaMulti: Sized {
934934
mod assertions {
935935
use super::*;
936936

937+
#[cfg(not(feature = "send"))]
937938
static_assertions::assert_not_impl_any!(Value: Send);
939+
#[cfg(not(feature = "send"))]
938940
static_assertions::assert_not_impl_any!(MultiValue: Send);
941+
942+
#[cfg(feature = "send")]
943+
static_assertions::assert_impl_all!(Value: Send, Sync);
944+
#[cfg(feature = "send")]
945+
static_assertions::assert_impl_all!(MultiValue: Send, Sync);
939946
}

0 commit comments

Comments
 (0)