From da496def163b9100ffc4240ad45cbe5f88312732 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 12 May 2024 07:31:35 -0400 Subject: [PATCH] revert to using .get() for function calls --- reactive_graph/src/nightly.rs | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/reactive_graph/src/nightly.rs b/reactive_graph/src/nightly.rs index 9bcda5915..e4e7c64b7 100644 --- a/reactive_graph/src/nightly.rs +++ b/reactive_graph/src/nightly.rs @@ -122,6 +122,44 @@ macro_rules! impl_get_fn_traits_read_send { }; } +macro_rules! impl_get_fn_traits_get { + ($($ty:ident $(($method_name:ident))?),*) => { + $( + #[cfg(feature = "nightly")] + impl FnOnce<()> for $ty { + type Output = ::Value; + + #[inline(always)] + extern "rust-call" fn call_once(self, _args: ()) -> Self::Output { + impl_get_fn_traits_get_send!(@method_name self $($method_name)?) + } + } + + #[cfg(feature = "nightly")] + impl FnMut<()> for $ty { + #[inline(always)] + extern "rust-call" fn call_mut(&mut self, _args: ()) -> Self::Output { + impl_get_fn_traits_get_send!(@method_name self $($method_name)?) + } + } + + #[cfg(feature = "nightly")] + impl Fn<()> for $ty { + #[inline(always)] + extern "rust-call" fn call(&self, _args: ()) -> Self::Output { + impl_get_fn_traits_get_send!(@method_name self $($method_name)?) + } + } + )* + }; + (@method_name $self:ident) => { + $self.get() + }; + (@method_name $self:ident $ident:ident) => { + $self.$ident() + }; +} + macro_rules! impl_get_fn_traits_get_send { ($($ty:ident $(($method_name:ident))?),*) => { $( @@ -197,8 +235,8 @@ macro_rules! impl_set_fn_traits_send { }; } -impl_get_fn_traits_read![ArcReadSignal, ArcRwSignal]; +impl_get_fn_traits_get![ArcReadSignal, ArcRwSignal]; impl_get_fn_traits_get_send![ArcSignal, Signal]; -impl_get_fn_traits_read_send![ReadSignal, RwSignal, Memo, ArcMemo]; +impl_get_fn_traits_get_send![ReadSignal, RwSignal, Memo, ArcMemo]; impl_set_fn_traits![ArcWriteSignal]; impl_set_fn_traits_send![WriteSignal];