Skip to content

Commit fbc660d

Browse files
committed
Require functions to be Send + Sync
1 parent 4fef318 commit fbc660d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/bevy_reflect/src/func/function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub type FunctionResult<'a> = Result<Return<'a>, FunctionError>;
9191
/// ```
9292
pub struct DynamicFunction<'env> {
9393
info: FunctionInfo,
94-
func: Box<dyn for<'a> FnMut(ArgList<'a>, &FunctionInfo) -> FunctionResult<'a> + 'env>,
94+
func: Box<dyn for<'a> FnMut(ArgList<'a>, &FunctionInfo) -> FunctionResult<'a> + Send + Sync + 'env>,
9595
}
9696

9797
impl<'env> DynamicFunction<'env> {
@@ -101,7 +101,7 @@ impl<'env> DynamicFunction<'env> {
101101
///
102102
/// It's important that the function signature matches the provided [`FunctionInfo`].
103103
/// This info is used to validate the arguments and return value.
104-
pub fn new<F: for<'a> FnMut(ArgList<'a>, &FunctionInfo) -> FunctionResult<'a> + 'env>(
104+
pub fn new<F: for<'a> FnMut(ArgList<'a>, &FunctionInfo) -> FunctionResult<'a> + Send + Sync + 'env>(
105105
func: F,
106106
info: FunctionInfo,
107107
) -> Self {

crates/bevy_reflect/src/func/into_function.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ macro_rules! impl_into_function {
118118
R: $crate::func::IntoReturn + $crate::func::args::GetOwnership + $crate::TypePath,
119119
F: FnMut($($Arg),*) -> R + 'env,
120120
F: for<'a> FnMut($($Arg::Item<'a>),*) -> R + 'env,
121+
F: Send + Sync,
121122
{
122123
fn into_function(mut self) -> $crate::func::DynamicFunction<'env> {
123124
const COUNT: usize = count_tts!($($Arg)*);
@@ -166,6 +167,7 @@ macro_rules! impl_into_function {
166167
$($Arg: $crate::func::args::FromArg + $crate::func::args::GetOwnership + $crate::TypePath,)*
167168
F: for<'a> FnMut(&'a Receiver, $($Arg),*) -> &'a R + 'env,
168169
F: for<'a> FnMut(&'a Receiver, $($Arg::Item<'a>),*) -> &'a R + 'env,
170+
F: Send + Sync,
169171
{
170172
fn into_function(mut self) -> $crate::func::DynamicFunction<'env> {
171173
const COUNT: usize = count_tts!(Receiver $($Arg)*);
@@ -217,6 +219,7 @@ macro_rules! impl_into_function {
217219
$($Arg: $crate::func::args::FromArg + $crate::func::args::GetOwnership + $crate::TypePath,)*
218220
F: for<'a> FnMut(&'a mut Receiver, $($Arg),*) -> &'a mut R + 'env,
219221
F: for<'a> FnMut(&'a mut Receiver, $($Arg::Item<'a>),*) -> &'a mut R + 'env,
222+
F: Send + Sync,
220223
{
221224
fn into_function(mut self) -> $crate::func::DynamicFunction<'env> {
222225
const COUNT: usize = count_tts!(Receiver $($Arg)*);
@@ -268,6 +271,7 @@ macro_rules! impl_into_function {
268271
$($Arg: $crate::func::args::FromArg + $crate::func::args::GetOwnership + $crate::TypePath,)*
269272
F: for<'a> FnMut(&'a mut Receiver, $($Arg),*) -> &'a R + 'env,
270273
F: for<'a> FnMut(&'a mut Receiver, $($Arg::Item<'a>),*) -> &'a R + 'env,
274+
F: Send + Sync,
271275
{
272276
fn into_function(mut self) -> $crate::func::DynamicFunction<'env> {
273277
const COUNT: usize = count_tts!(Receiver $($Arg)*);

0 commit comments

Comments
 (0)