From 9d6faef3d37c7d6457eedbcc365c1d9548788746 Mon Sep 17 00:00:00 2001 From: Andy Weidenbaum Date: Mon, 29 Mar 2021 12:40:32 +1100 Subject: [PATCH] ClosureSearcher.modules HashMap --- src/searcher.rs | 8 ++++---- tests/tests.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/searcher.rs b/src/searcher.rs index aa4a16d..74ebfa2 100644 --- a/src/searcher.rs +++ b/src/searcher.rs @@ -153,7 +153,7 @@ pub struct ClosureSearcher { /// Closures must return an `rlua::Result`-wrapped `Function`. This `Function` /// acts as the module loader. modules: HashMap< - &'static str, + String, Box< dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> rlua::Result> + Send, @@ -166,7 +166,7 @@ pub struct ClosureSearcher { impl ClosureSearcher { pub fn new( modules: HashMap< - &'static str, + String, Box< dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> rlua::Result> + Send, @@ -232,7 +232,7 @@ pub trait AddSearcher { fn add_closure_searcher( &self, modules: HashMap< - &'static str, + String, Box< dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> rlua::Result> + Send, @@ -297,7 +297,7 @@ impl<'a> AddSearcher for Context<'a> { fn add_closure_searcher( &self, modules: HashMap< - &'static str, + String, Box< dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> rlua::Result> + Send, diff --git a/tests/tests.rs b/tests/tests.rs index 2d3457d..c2f352b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -165,7 +165,7 @@ fn add_closure_searcher_works() { let lua = Lua::new(); let mut modules: HashMap< - &'static str, + String, Box< dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> rlua::Result> + Send, @@ -189,7 +189,7 @@ fn add_closure_searcher_works() { .into_function()?) }); - modules.insert("instrument", instrument_loader); + modules.insert("instrument".to_string(), instrument_loader); let sound = lua .context::<_, Result>(|lua_ctx| {