From 53432900c181f2a30b2aa3a1dbcd8b0f48af55bf Mon Sep 17 00:00:00 2001 From: Andy Weidenbaum Date: Thu, 4 Mar 2021 12:22:40 +1100 Subject: [PATCH] s/PolySearcher/PathSearcherPoly, convert/transform s/add_poly_searcher/add_path_searcher_poly --- src/searcher.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/searcher.rs b/src/searcher.rs index 3363a8a..8278a9d 100644 --- a/src/searcher.rs +++ b/src/searcher.rs @@ -77,7 +77,7 @@ impl UserData for StaticSearcher { /// /// Facilitates Lua module reloading, and module reloading of any other programming /// language whose source code can be compiled to Lua. -struct PolySearcher

+struct PathSearcherPoly

where P: 'static + AsRef + Send, { @@ -85,27 +85,27 @@ where globals: RegistryKey, /// Function to read file content as Lua source code. - convert: Box rlua::Result + Send>, + transform: Box rlua::Result + Send>, } -impl

PolySearcher

+impl

PathSearcherPoly

where P: 'static + AsRef + Send, { fn new( modules: HashMap, globals: RegistryKey, - convert: Box rlua::Result + Send>, + transform: Box rlua::Result + Send>, ) -> Self { Self { modules, globals, - convert, + transform, } } } -impl

UserData for PolySearcher

+impl

UserData for PathSearcherPoly

where P: 'static + AsRef + Send, { @@ -122,7 +122,7 @@ where path.to_path_buf() }; - let content = (this.convert)(path)?; + let content = (this.transform)(path)?; Ok(Value::Function( lua_ctx @@ -155,12 +155,12 @@ pub trait AddSearcher { where P: 'static + AsRef + Send; - /// Like `add_path_searcher`, but with user-provided closure for converting source - /// code to Lua. - fn add_poly_searcher

( + /// Like `add_path_searcher`, but with user-provided closure for transforming + /// source code to Lua. + fn add_path_searcher_poly

( &self, modules: HashMap, - convert: Box rlua::Result + Send>, + transform: Box rlua::Result + Send>, ) -> Result<()> where P: 'static + AsRef + Send; @@ -191,7 +191,7 @@ impl<'a> AddSearcher for Context<'a> { where P: 'static + AsRef + Send, { - let convert = Box::new(|path| { + let transform = Box::new(|path| { let mut content = String::new(); let mut file = File::open(path) .map_err(|e| LuaError::RuntimeError(format!("io error: {:#?}", e)))?; @@ -199,13 +199,13 @@ impl<'a> AddSearcher for Context<'a> { .map_err(|e| LuaError::RuntimeError(format!("io error: {:#?}", e)))?; Ok(content) }); - self.add_poly_searcher(modules, convert) + self.add_path_searcher_poly(modules, transform) } - fn add_poly_searcher

( + fn add_path_searcher_poly

( &self, modules: HashMap, - convert: Box rlua::Result + Send>, + transform: Box rlua::Result + Send>, ) -> Result<()> where P: 'static + AsRef + Send, @@ -213,7 +213,7 @@ impl<'a> AddSearcher for Context<'a> { let globals = self.globals(); let searchers: Table = globals.get::<_, Table>("package")?.get("searchers")?; let registry_key = self.create_registry_value(globals)?; - let searcher = PolySearcher::new(modules, registry_key, convert); + let searcher = PathSearcherPoly::new(modules, registry_key, transform); searchers .set(searchers.len()? + 1, searcher) .map_err(|e| e.into())