From 77cbc4e35518f10aabcec4fb2e03585d139790ee Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Mon, 1 Apr 2024 15:08:52 -0400 Subject: [PATCH] [runtime] relax Fn trait bound --- rura-internal-macros/src/lib.rs | 2 +- rura-runtime/src/closure.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rura-internal-macros/src/lib.rs b/rura-internal-macros/src/lib.rs index a62511e..bd3244f 100644 --- a/rura-internal-macros/src/lib.rs +++ b/rura-internal-macros/src/lib.rs @@ -45,7 +45,7 @@ fn generate_from_impl(total_cnt: usize) -> TokenStream { quote::quote! { impl<#(#full_ident : Clone + 'static,)*R : 'static, F> From for Closure<(#(#full_ident,)*), R> - where F : Fn((#(#full_ident,)*)) -> R + Clone + 'static + where F : FnOnce((#(#full_ident,)*)) -> R + Clone + 'static { fn from(code: F) -> Self { Closure (Rc::new(Thunk { diff --git a/rura-runtime/src/closure.rs b/rura-runtime/src/closure.rs index edb0bcd..efebfd9 100644 --- a/rura-runtime/src/closure.rs +++ b/rura-runtime/src/closure.rs @@ -38,7 +38,7 @@ rura_internal_macros::generate_from_impls!(); pub struct Thunk where - F: Fn(P::Full) -> R + Clone, + F: FnOnce(P::Full) -> R + Clone, { code: F, params: P, @@ -46,7 +46,7 @@ where impl Clone for Thunk where - F: Fn(P::Full) -> R + Clone, + F: FnOnce(P::Full) -> R + Clone, { fn clone(&self) -> Self { Thunk { @@ -64,7 +64,7 @@ pub trait BoxedClosure { impl BoxedClosure for Thunk where - F: Fn(P::Full) -> R + Clone + 'static, + F: FnOnce(P::Full) -> R + Clone + 'static, P: PartialParams + Clone + 'static, R: 'static, {