diff --git a/crates/bevy_reflect/derive/src/impls/func/from_arg.rs b/crates/bevy_reflect/derive/src/impls/func/from_arg.rs index d69668de26..1e92900fc7 100644 --- a/crates/bevy_reflect/derive/src/impls/func/from_arg.rs +++ b/crates/bevy_reflect/derive/src/impls/func/from_arg.rs @@ -13,7 +13,9 @@ pub(crate) fn impl_from_arg(where_clause_options: &WhereClauseOptions) -> proc_m quote! { impl #impl_generics #bevy_reflect::func::args::FromArg for #type_path #ty_generics #where_reflect_clause { type This<'from_arg> = #type_path #ty_generics; - fn from_arg(arg: #bevy_reflect::func::args::Arg) -> #FQResult, #bevy_reflect::func::args::ArgError> { + fn from_arg(arg: #bevy_reflect::func::args::Arg) -> + #FQResult, #bevy_reflect::func::args::ArgError> + { arg.take_owned() } } diff --git a/crates/bevy_reflect/derive/src/impls/func/into_return.rs b/crates/bevy_reflect/derive/src/impls/func/into_return.rs index 47e70b8379..73386f9f8a 100644 --- a/crates/bevy_reflect/derive/src/impls/func/into_return.rs +++ b/crates/bevy_reflect/derive/src/impls/func/into_return.rs @@ -13,7 +13,9 @@ pub(crate) fn impl_into_return( quote! { impl #impl_generics #bevy_reflect::func::IntoReturn for #type_path #ty_generics #where_reflect_clause { - fn into_return<'into_return>(self) -> #bevy_reflect::func::Return<'into_return> where Self: 'into_return { + fn into_return<'into_return>(self) -> #bevy_reflect::func::Return<'into_return> + where Self: 'into_return + { #bevy_reflect::func::Return::Owned(#bevy_reflect::__macro_exports::alloc_utils::Box::new(self)) } } diff --git a/crates/bevy_reflect/src/func/args/from_arg.rs b/crates/bevy_reflect/src/func/args/from_arg.rs index 7cd24e73f7..c49d065169 100644 --- a/crates/bevy_reflect/src/func/args/from_arg.rs +++ b/crates/bevy_reflect/src/func/args/from_arg.rs @@ -59,18 +59,13 @@ macro_rules! impl_from_arg { ( $ty: ty $(; - < - $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* - > + < $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* > )? $( - [ - $(const $N: ident : $size: ident),* - ] + [ $(const $N: ident : $size: ident),* ] )? $( - where - $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* + where $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* )? ) => { impl < @@ -78,12 +73,13 @@ macro_rules! impl_from_arg { $(, $(const $N : $size),*)? > $crate::func::args::FromArg for $ty $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? { type This<'from_arg> = $ty; - fn from_arg(arg: $crate::func::args::Arg) -> Result, $crate::func::args::ArgError> { + fn from_arg(arg: $crate::func::args::Arg) -> + Result, $crate::func::args::ArgError> + { arg.take_owned() } } diff --git a/crates/bevy_reflect/src/func/args/ownership.rs b/crates/bevy_reflect/src/func/args/ownership.rs index 50a0fd51c2..449cc67cd8 100644 --- a/crates/bevy_reflect/src/func/args/ownership.rs +++ b/crates/bevy_reflect/src/func/args/ownership.rs @@ -65,18 +65,13 @@ macro_rules! impl_get_ownership { ( $ty: ty $(; - < - $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* - > + < $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* > )? $( - [ - $(const $N: ident : $size: ident),* - ] + [ $(const $N: ident : $size: ident),* ] )? $( - where - $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* + where $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* )? ) => { impl < @@ -84,8 +79,7 @@ macro_rules! impl_get_ownership { $(, $(const $N : $size),*)? > $crate::func::args::GetOwnership for $ty $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? {} }; diff --git a/crates/bevy_reflect/src/func/macros.rs b/crates/bevy_reflect/src/func/macros.rs index 3fb93a2230..5ceb2e270e 100644 --- a/crates/bevy_reflect/src/func/macros.rs +++ b/crates/bevy_reflect/src/func/macros.rs @@ -28,69 +28,49 @@ macro_rules! impl_function_traits { ( $ty: ty $(; - < - $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* - > + < $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* > )? $( - [ - $(const $N: ident : $size: ident),* - ] + [ $(const $N: ident : $size: ident),* ] )? $( - where - $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* + where $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* )? ) => { $crate::func::args::impl_get_ownership!( $ty $(; - < - $($T $(: $T1 $(+ $T2)*)?),* - > + < $($T $(: $T1 $(+ $T2)*)?),* > )? $( - [ - $(const $N : $size),* - ] + [ $(const $N : $size),* ] )? $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? ); $crate::func::args::impl_from_arg!( $ty $(; - < - $($T $(: $T1 $(+ $T2)*)?),* - > + < $($T $(: $T1 $(+ $T2)*)?),* > )? $( - [ - $(const $N : $size),* - ] + [ $(const $N : $size),* ] )? $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? ); $crate::func::impl_into_return!( $ty $(; - < - $($T $(: $T1 $(+ $T2)*)?),* - > + < $($T $(: $T1 $(+ $T2)*)?),* > )? $( - [ - $(const $N : $size),* - ] + [ $(const $N : $size),* ] )? $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? ); }; diff --git a/crates/bevy_reflect/src/func/return_type.rs b/crates/bevy_reflect/src/func/return_type.rs index 79d4f617cf..06c308b6b2 100644 --- a/crates/bevy_reflect/src/func/return_type.rs +++ b/crates/bevy_reflect/src/func/return_type.rs @@ -126,18 +126,13 @@ macro_rules! impl_into_return { ( $ty: ty $(; - < - $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* - > + < $($T: ident $(: $T1: tt $(+ $T2: tt)*)?),* > )? $( - [ - $(const $N: ident : $size: ident),* - ] + [ $(const $N: ident : $size: ident),* ] )? $( - where - $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* + where $($U: ty $(: $U1: tt $(+ $U2: tt)*)?),* )? ) => { impl < @@ -145,11 +140,12 @@ macro_rules! impl_into_return { $(, $(const $N : $size),*)? > $crate::func::IntoReturn for $ty $( - where - $($U $(: $U1 $(+ $U2)*)?),* + where $($U $(: $U1 $(+ $U2)*)?),* )? { - fn into_return<'into_return>(self) -> $crate::func::Return<'into_return> where Self: 'into_return { + fn into_return<'into_return>(self) -> $crate::func::Return<'into_return> + where Self: 'into_return + { $crate::func::Return::Owned(bevy_platform::prelude::Box::new(self)) } }