From d0766a116f743d871064c712708e405a2dff5721 Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 23 Apr 2024 14:35:11 +0800 Subject: [PATCH] core: Remove Box from GenCallCallback type alias So that references to the function type can be taken. --- nac3core/src/toplevel/builtins.rs | 2 +- nac3core/src/toplevel/mod.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/nac3core/src/toplevel/builtins.rs b/nac3core/src/toplevel/builtins.rs index 44057093e..282c1a994 100644 --- a/nac3core/src/toplevel/builtins.rs +++ b/nac3core/src/toplevel/builtins.rs @@ -108,7 +108,7 @@ fn create_fn_by_codegen( name: &'static str, ret_ty: Type, param_ty: &[(Type, &'static str)], - codegen_callback: GenCallCallback, + codegen_callback: Box, ) -> Arc> { Arc::new(RwLock::new(TopLevelDef::Function { name: name.into(), diff --git a/nac3core/src/toplevel/mod.rs b/nac3core/src/toplevel/mod.rs index 1209f51ff..6edaeca5f 100644 --- a/nac3core/src/toplevel/mod.rs +++ b/nac3core/src/toplevel/mod.rs @@ -32,7 +32,7 @@ use type_annotation::*; #[cfg(test)] mod test; -type GenCallCallback = Box< +type GenCallCallback = dyn for<'ctx, 'a> Fn( &mut CodeGenContext<'ctx, 'a>, Option<(Type, ValueEnum<'ctx>)>, @@ -41,16 +41,15 @@ type GenCallCallback = Box< &mut dyn CodeGenerator, ) -> Result>, String> + Send - + Sync, ->; + + Sync; pub struct GenCall { - fp: GenCallCallback, + fp: Box, } impl GenCall { #[must_use] - pub fn new(fp: GenCallCallback) -> GenCall { + pub fn new(fp: Box) -> GenCall { GenCall { fp } }