From a86d6ab330983f88fe8defd80aa0e297edb5c8fb Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 31 Jul 2024 11:13:48 +0100 Subject: [PATCH] Mark `LightUserData` as Send+Sync (`send` feature flag) --- src/types.rs | 5 +++++ src/value.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/types.rs b/src/types.rs index 8c6810e..9060bfa 100644 --- a/src/types.rs +++ b/src/types.rs @@ -41,6 +41,11 @@ pub(crate) enum SubtypeId { #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct LightUserData(pub *mut c_void); +#[cfg(feature = "send")] +unsafe impl Send for LightUserData {} +#[cfg(feature = "send")] +unsafe impl Sync for LightUserData {} + pub(crate) type Callback<'a> = Box Result + 'static>; pub(crate) struct Upvalue { diff --git a/src/value.rs b/src/value.rs index fe2a27d..2429910 100644 --- a/src/value.rs +++ b/src/value.rs @@ -934,6 +934,13 @@ pub trait FromLuaMulti: Sized { mod assertions { use super::*; + #[cfg(not(feature = "send"))] static_assertions::assert_not_impl_any!(Value: Send); + #[cfg(not(feature = "send"))] static_assertions::assert_not_impl_any!(MultiValue: Send); + + #[cfg(feature = "send")] + static_assertions::assert_impl_all!(Value: Send, Sync); + #[cfg(feature = "send")] + static_assertions::assert_impl_all!(MultiValue: Send, Sync); }