Clean up some lifetime specification

This commit is contained in:
kyren 2018-03-19 14:35:46 -04:00
parent 985636267c
commit 4b6809c766
3 changed files with 12 additions and 10 deletions

View File

@ -37,7 +37,7 @@ impl<'lua> FromLua<'lua> for String<'lua> {
} }
impl<'lua> ToLua<'lua> for Table<'lua> { impl<'lua> ToLua<'lua> for Table<'lua> {
fn to_lua(self, _: &'lua Lua) -> Result<Value> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Table(self)) Ok(Value::Table(self))
} }
} }
@ -270,14 +270,16 @@ impl<'lua, T: FromLua<'lua>> FromLua<'lua> for Vec<T> {
} }
impl<'lua, K: Eq + Hash + ToLua<'lua>, V: ToLua<'lua>, S: BuildHasher> ToLua<'lua> impl<'lua, K: Eq + Hash + ToLua<'lua>, V: ToLua<'lua>, S: BuildHasher> ToLua<'lua>
for HashMap<K, V, S> { for HashMap<K, V, S>
{
fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Table(lua.create_table_from(self)?)) Ok(Value::Table(lua.create_table_from(self)?))
} }
} }
impl<'lua, K: Eq + Hash + FromLua<'lua>, V: FromLua<'lua>, S: BuildHasher + Default> FromLua<'lua> impl<'lua, K: Eq + Hash + FromLua<'lua>, V: FromLua<'lua>, S: BuildHasher + Default> FromLua<'lua>
for HashMap<K, V, S> { for HashMap<K, V, S>
{
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Self> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Self> {
if let Value::Table(table) = value { if let Value::Table(table) = value {
table.pairs().collect() table.pairs().collect()

View File

@ -139,7 +139,7 @@ impl<'lua, T: FromLua<'lua>> FromLuaMulti<'lua> for Variadic<T> {
macro_rules! impl_tuple { macro_rules! impl_tuple {
() => ( () => (
impl<'lua> ToLuaMulti<'lua> for () { impl<'lua> ToLuaMulti<'lua> for () {
fn to_lua_multi(self, _: &'lua Lua) -> Result<MultiValue> { fn to_lua_multi(self, _: &'lua Lua) -> Result<MultiValue<'lua>> {
Ok(MultiValue::new()) Ok(MultiValue::new())
} }
} }

View File

@ -89,7 +89,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> Fn(&'lua Lua, &'a T, A) -> Result<R>, M: 'static + Send + Fn(&'lua Lua, &T, A) -> Result<R>,
{ {
self.methods self.methods
.insert(name.to_owned(), Self::box_method(method)); .insert(name.to_owned(), Self::box_method(method));
@ -104,7 +104,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> FnMut(&'lua Lua, &'a mut T, A) -> Result<R>, M: 'static + Send + FnMut(&'lua Lua, &mut T, A) -> Result<R>,
{ {
self.methods self.methods
.insert(name.to_owned(), Self::box_method_mut(method)); .insert(name.to_owned(), Self::box_method_mut(method));
@ -155,7 +155,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> Fn(&'lua Lua, &'a T, A) -> Result<R>, M: 'static + Send + Fn(&'lua Lua, &T, A) -> Result<R>,
{ {
self.meta_methods.insert(meta, Self::box_method(method)); self.meta_methods.insert(meta, Self::box_method(method));
} }
@ -172,7 +172,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> FnMut(&'lua Lua, &'a mut T, A) -> Result<R>, M: 'static + Send + FnMut(&'lua Lua, &mut T, A) -> Result<R>,
{ {
self.meta_methods.insert(meta, Self::box_method_mut(method)); self.meta_methods.insert(meta, Self::box_method_mut(method));
} }
@ -234,7 +234,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> Fn(&'lua Lua, &'a T, A) -> Result<R>, M: 'static + Send + Fn(&'lua Lua, &T, A) -> Result<R>,
{ {
Box::new(move |lua, mut args| { Box::new(move |lua, mut args| {
if let Some(front) = args.pop_front() { if let Some(front) = args.pop_front() {
@ -255,7 +255,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
where where
A: FromLuaMulti<'lua>, A: FromLuaMulti<'lua>,
R: ToLuaMulti<'lua>, R: ToLuaMulti<'lua>,
M: 'static + Send + for<'a> FnMut(&'lua Lua, &'a mut T, A) -> Result<R>, M: 'static + Send + FnMut(&'lua Lua, &mut T, A) -> Result<R>,
{ {
let method = RefCell::new(method); let method = RefCell::new(method);
Box::new(move |lua, mut args| { Box::new(move |lua, mut args| {