From 0b09ac03d608ad14653073c98cc99faf3d1b095d Mon Sep 17 00:00:00 2001 From: Andy Weidenbaum Date: Wed, 24 Mar 2021 07:53:43 +1100 Subject: [PATCH] prefer where syntax --- src/searcher.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/searcher.rs b/src/searcher.rs index ccda749..e415d12 100644 --- a/src/searcher.rs +++ b/src/searcher.rs @@ -25,7 +25,10 @@ impl Searcher { } impl UserData for Searcher { - fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { + fn add_methods<'lua, M>(methods: &mut M) + where + M: UserDataMethods<'lua, Self>, + { methods.add_meta_method(MetaMethod::Call, |lua_ctx, this, name: String| { match this.modules.get(&name) { Some(content) => Ok(Value::Function( @@ -55,7 +58,10 @@ impl StaticSearcher { } impl UserData for StaticSearcher { - fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { + fn add_methods<'lua, M>(methods: &mut M) + where + M: UserDataMethods<'lua, Self>, + { methods.add_meta_method(MetaMethod::Call, |lua_ctx, this, name: String| { match this.modules.get(name.as_str()) { Some(content) => Ok(Value::Function( @@ -108,7 +114,10 @@ impl

UserData for PathSearcherPoly

where P: 'static + AsRef + Send, { - fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { + fn add_methods<'lua, M>(methods: &mut M) + where + M: UserDataMethods<'lua, Self>, + { methods.add_meta_method(MetaMethod::Call, |lua_ctx, this, name: String| { match this.modules.get(&name) { Some(ref path) => {