summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2024-05-18 01:03:25 +0100
committerAlex Orlenko <zxteam@protonmail.com>2024-06-24 15:09:24 +0100
commitfc9475b4959ce23e3bb420b42a95543e4f55bac2 (patch)
treee14741cb6bd12fb7582f580c5eabd58858385d2b
parent965208b84c14b817836119dd1252289cb7f31014 (diff)
downloadmlua-fc9475b4959ce23e3bb420b42a95543e4f55bac2.zip
Drop lifetime from IntoLua
-rw-r--r--src/chunk.rs6
-rw-r--r--src/conversion.rs255
-rw-r--r--src/function.rs38
-rw-r--r--src/lua.rs30
-rw-r--r--src/multi.rs46
-rw-r--r--src/scope.rs42
-rw-r--r--src/table.rs50
-rw-r--r--src/thread.rs8
-rw-r--r--src/userdata.rs52
-rw-r--r--src/userdata_ext.rs32
-rw-r--r--src/userdata_impl.rs54
-rw-r--r--src/value.rs12
12 files changed, 314 insertions, 311 deletions
diff --git a/src/chunk.rs b/src/chunk.rs
index b3b1a7c..9de6f47 100644
--- a/src/chunk.rs
+++ b/src/chunk.rs
@@ -308,7 +308,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
/// All global variables (including the standard library!) are looked up in `_ENV`, so it may be
/// necessary to populate the environment in order for scripts using custom environments to be
/// useful.
- pub fn set_environment<V: IntoLua<'lua>>(mut self, env: V) -> Self {
+ pub fn set_environment<V: IntoLua>(mut self, env: V) -> Self {
self.env = env
.into_lua(self.lua)
.and_then(|val| self.lua.unpack(val))
@@ -402,7 +402,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
/// Load the chunk function and call it with the given arguments.
///
/// This is equivalent to `into_function` and calling the resulting function.
- pub fn call<A: IntoLuaMulti<'lua>, R: FromLuaMulti<'lua>>(self, args: A) -> Result<R> {
+ pub fn call<A: IntoLuaMulti, R: FromLuaMulti<'lua>>(self, args: A) -> Result<R> {
self.into_function()?.call(args)
}
@@ -417,7 +417,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn call_async<A, R>(self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
self.into_function()?.call_async(args).await
diff --git a/src/conversion.rs b/src/conversion.rs
index 3dfcbc8..f521097 100644
--- a/src/conversion.rs
+++ b/src/conversion.rs
@@ -2,6 +2,7 @@ use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::ffi::{CStr, CString};
use std::hash::{BuildHasher, Hash};
+use std::mem::transmute;
use std::os::raw::c_int;
use std::string::String as StdString;
use std::{slice, str};
@@ -25,21 +26,21 @@ use crate::{
userdata::OwnedAnyUserData,
};
-impl<'lua> IntoLua<'lua> for Value<'lua> {
+impl IntoLua for Value<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(self)
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(transmute(self)) }
}
}
-impl<'lua> IntoLua<'lua> for &Value<'lua> {
+impl IntoLua for &Value<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(self.clone())
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(transmute(self.clone())) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_value(self)
}
}
@@ -51,21 +52,21 @@ impl<'lua> FromLua<'lua> for Value<'lua> {
}
}
-impl<'lua> IntoLua<'lua> for String<'lua> {
+impl IntoLua for String<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::String(self))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::String(transmute(self))) }
}
}
-impl<'lua> IntoLua<'lua> for &String<'lua> {
+impl IntoLua for &String<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::String(self.clone()))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::String(transmute(self.clone()))) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_ref(&self.0);
Ok(())
}
@@ -86,18 +87,18 @@ impl<'lua> FromLua<'lua> for String<'lua> {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for OwnedString {
+impl IntoLua for OwnedString {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &'_ Lua) -> Result<Value<'_>> {
Ok(Value::String(String(lua.adopt_owned_ref(self.0))))
}
}
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for &OwnedString {
+impl IntoLua for &OwnedString {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
OwnedString::into_lua(self.clone(), lua)
}
@@ -117,21 +118,21 @@ impl<'lua> FromLua<'lua> for OwnedString {
}
}
-impl<'lua> IntoLua<'lua> for Table<'lua> {
+impl IntoLua for Table<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Table(self))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Table(transmute(self))) }
}
}
-impl<'lua> IntoLua<'lua> for &Table<'lua> {
+impl IntoLua for &Table<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Table(self.clone()))
+ fn into_lua(self, _: &'_ Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Table(transmute(self.clone()))) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_ref(&self.0);
Ok(())
}
@@ -153,18 +154,18 @@ impl<'lua> FromLua<'lua> for Table<'lua> {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for OwnedTable {
+impl IntoLua for OwnedTable {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(Table(lua.adopt_owned_ref(self.0))))
}
}
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for &OwnedTable {
+impl IntoLua for &OwnedTable {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
OwnedTable::into_lua(self.clone(), lua)
}
@@ -184,21 +185,21 @@ impl<'lua> FromLua<'lua> for OwnedTable {
}
}
-impl<'lua> IntoLua<'lua> for Function<'lua> {
+impl IntoLua for Function<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Function(self))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Function(transmute(self))) }
}
}
-impl<'lua> IntoLua<'lua> for &Function<'lua> {
+impl IntoLua for &Function<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Function(self.clone()))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Function(transmute(self.clone()))) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_ref(&self.0);
Ok(())
}
@@ -220,18 +221,18 @@ impl<'lua> FromLua<'lua> for Function<'lua> {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for OwnedFunction {
+impl IntoLua for OwnedFunction {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Function(Function(lua.adopt_owned_ref(self.0))))
}
}
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for &OwnedFunction {
+impl IntoLua for &OwnedFunction {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
OwnedFunction::into_lua(self.clone(), lua)
}
@@ -251,21 +252,21 @@ impl<'lua> FromLua<'lua> for OwnedFunction {
}
}
-impl<'lua> IntoLua<'lua> for Thread<'lua> {
+impl IntoLua for Thread<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Thread(self))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Thread(transmute(self))) }
}
}
-impl<'lua> IntoLua<'lua> for &Thread<'lua> {
+impl IntoLua for &Thread<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::Thread(self.clone()))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::Thread(transmute(self.clone()))) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_ref(&self.0);
Ok(())
}
@@ -287,18 +288,18 @@ impl<'lua> FromLua<'lua> for Thread<'lua> {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for OwnedThread {
+impl IntoLua for OwnedThread {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Thread(Thread(lua.adopt_owned_ref(self.0), self.1)))
}
}
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for &OwnedThread {
+impl IntoLua for &OwnedThread {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
OwnedThread::into_lua(self.clone(), lua)
}
@@ -318,21 +319,21 @@ impl<'lua> FromLua<'lua> for OwnedThread {
}
}
-impl<'lua> IntoLua<'lua> for AnyUserData<'lua> {
+impl IntoLua for AnyUserData<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::UserData(self))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::UserData(transmute(self))) }
}
}
-impl<'lua> IntoLua<'lua> for &AnyUserData<'lua> {
+impl IntoLua for &AnyUserData<'_> {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
- Ok(Value::UserData(self.clone()))
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
+ unsafe { Ok(Value::UserData(transmute(self.clone()))) }
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_ref(&self.0);
Ok(())
}
@@ -354,9 +355,9 @@ impl<'lua> FromLua<'lua> for AnyUserData<'lua> {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for OwnedAnyUserData {
+impl IntoLua for OwnedAnyUserData {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::UserData(AnyUserData(
lua.adopt_owned_ref(self.0),
self.1,
@@ -366,9 +367,9 @@ impl<'lua> IntoLua<'lua> for OwnedAnyUserData {
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
-impl<'lua> IntoLua<'lua> for &OwnedAnyUserData {
+impl IntoLua for &OwnedAnyUserData {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
OwnedAnyUserData::into_lua(self.clone(), lua)
}
@@ -388,9 +389,9 @@ impl<'lua> FromLua<'lua> for OwnedAnyUserData {
}
}
-impl<'lua, T: UserData + MaybeSend + 'static> IntoLua<'lua> for T {
+impl<T: UserData + MaybeSend + 'static> IntoLua for T {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::UserData(lua.create_userdata(self)?))
}
}
@@ -409,9 +410,9 @@ impl<'lua, T: 'static> FromLua<'lua> for UserDataRefMut<'lua, T> {
}
}
-impl<'lua> IntoLua<'lua> for Error {
+impl IntoLua for Error {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
Ok(Value::Error(Box::new(self)))
}
}
@@ -430,25 +431,25 @@ impl<'lua> FromLua<'lua> for Error {
}
}
-impl<'lua> IntoLua<'lua> for RegistryKey {
+impl IntoLua for RegistryKey {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
lua.registry_value(&self)
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
<&RegistryKey>::push_into_stack(&self, lua)
}
}
-impl<'lua> IntoLua<'lua> for &RegistryKey {
+impl IntoLua for &RegistryKey {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
lua.registry_value(self)
}
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
if !lua.owns_registry_value(self) {
return Err(Error::MismatchedRegistryKey);
}
@@ -470,14 +471,14 @@ impl<'lua> FromLua<'lua> for RegistryKey {
}
}
-impl<'lua> IntoLua<'lua> for bool {
+impl IntoLua for bool {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
Ok(Value::Boolean(self))
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
ffi::lua_pushboolean(lua.state(), self as c_int);
Ok(())
}
@@ -499,9 +500,9 @@ impl<'lua> FromLua<'lua> for bool {
}
}
-impl<'lua> IntoLua<'lua> for LightUserData {
+impl IntoLua for LightUserData {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
Ok(Value::LightUserData(self))
}
}
@@ -521,9 +522,9 @@ impl<'lua> FromLua<'lua> for LightUserData {
}
#[cfg(feature = "luau")]
-impl<'lua> IntoLua<'lua> for crate::types::Vector {
+impl IntoLua for crate::types::Vector {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
Ok(Value::Vector(self))
}
}
@@ -543,14 +544,14 @@ impl<'lua> FromLua<'lua> for crate::types::Vector {
}
}
-impl<'lua> IntoLua<'lua> for StdString {
+impl IntoLua for StdString {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(&self)?))
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
push_bytes_into_stack(self, lua)
}
}
@@ -590,28 +591,28 @@ impl<'lua> FromLua<'lua> for StdString {
}
}
-impl<'lua> IntoLua<'lua> for &str {
+impl IntoLua for &str {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self)?))
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
push_bytes_into_stack(self, lua)
}
}
-impl<'lua> IntoLua<'lua> for Cow<'_, str> {
+impl IntoLua for Cow<'_, str> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self.as_bytes())?))
}
}
-impl<'lua> IntoLua<'lua> for Box<str> {
+impl IntoLua for Box<str> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(&*self)?))
}
}
@@ -633,9 +634,9 @@ impl<'lua> FromLua<'lua> for Box<str> {
}
}
-impl<'lua> IntoLua<'lua> for CString {
+impl IntoLua for CString {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self.as_bytes())?))
}
}
@@ -663,23 +664,23 @@ impl<'lua> FromLua<'lua> for CString {
}
}
-impl<'lua> IntoLua<'lua> for &CStr {
+impl IntoLua for &CStr {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self.to_bytes())?))
}
}
-impl<'lua> IntoLua<'lua> for Cow<'_, CStr> {
+impl IntoLua for Cow<'_, CStr> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self.to_bytes())?))
}
}
-impl<'lua> IntoLua<'lua> for BString {
+impl IntoLua for BString {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(&self)?))
}
}
@@ -731,9 +732,9 @@ impl<'lua> FromLua<'lua> for BString {
}
}
-impl<'lua> IntoLua<'lua> for &BStr {
+impl IntoLua for &BStr {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::String(lua.create_string(self)?))
}
}
@@ -741,7 +742,7 @@ impl<'lua> IntoLua<'lua> for &BStr {
#[inline]
unsafe fn push_bytes_into_stack<'lua, T>(this: T, lua: &'lua Lua) -> Result<()>
where
- T: IntoLua<'lua> + AsRef<[u8]>,
+ T: IntoLua + AsRef<[u8]>,
{
let bytes = this.as_ref();
if lua.unlikely_memory_error() && bytes.len() < (1 << 30) {
@@ -755,9 +756,9 @@ where
macro_rules! lua_convert_int {
($x:ty) => {
- impl<'lua> IntoLua<'lua> for $x {
+ impl IntoLua for $x {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
cast(self)
.map(Value::Integer)
.or_else(|| cast(self).map(Value::Number))
@@ -770,7 +771,7 @@ macro_rules! lua_convert_int {
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
match cast(self) {
Some(i) => ffi::lua_pushinteger(lua.state(), i),
None => ffi::lua_pushnumber(lua.state(), self as ffi::lua_Number),
@@ -827,9 +828,9 @@ lua_convert_int!(usize);
macro_rules! lua_convert_float {
($x:ty) => {
- impl<'lua> IntoLua<'lua> for $x {
+ impl IntoLua for $x {
#[inline]
- fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, _: &Lua) -> Result<Value<'_>> {
cast(self)
.ok_or_else(|| Error::ToLuaConversionError {
from: stringify!($x),
@@ -865,24 +866,24 @@ macro_rules! lua_convert_float {
lua_convert_float!(f32);
lua_convert_float!(f64);
-impl<'lua, T> IntoLua<'lua> for &[T]
+impl<T> IntoLua for &[T]
where
- T: IntoLua<'lua> + Clone,
+ T: IntoLua + Clone,
{
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(
lua.create_sequence_from(self.iter().cloned())?,
))
}
}
-impl<'lua, T, const N: usize> IntoLua<'lua> for [T; N]
+impl<T, const N: usize> IntoLua for [T; N]
where
- T: IntoLua<'lua>,
+ T: IntoLua,
{
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_sequence_from(self)?))
}
}
@@ -924,9 +925,9 @@ where
}
}
-impl<'lua, T: IntoLua<'lua>> IntoLua<'lua> for Box<[T]> {
+impl<T: IntoLua> IntoLua for Box<[T]> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_sequence_from(self.into_vec())?))
}
}
@@ -938,9 +939,9 @@ impl<'lua, T: FromLua<'lua>> FromLua<'lua> for Box<[T]> {
}
}
-impl<'lua, T: IntoLua<'lua>> IntoLua<'lua> for Vec<T> {
+impl<T: IntoLua> IntoLua for Vec<T> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_sequence_from(self)?))
}
}
@@ -959,11 +960,9 @@ impl<'lua, T: FromLua<'lua>> FromLua<'lua> for Vec<T> {
}
}
-impl<'lua, K: Eq + Hash + IntoLua<'lua>, V: IntoLua<'lua>, S: BuildHasher> IntoLua<'lua>
- for HashMap<K, V, S>
-{
+impl<K: Eq + Hash + IntoLua, V: IntoLua, S: BuildHasher> IntoLua for HashMap<K, V, S> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_table_from(self)?))
}
}
@@ -985,9 +984,9 @@ impl<'lua, K: Eq + Hash + FromLua<'lua>, V: FromLua<'lua>, S: BuildHasher + Defa
}
}
-impl<'lua, K: Ord + IntoLua<'lua>, V: IntoLua<'lua>> IntoLua<'lua> for BTreeMap<K, V> {
+impl<K: Ord + IntoLua, V: IntoLua> IntoLua for BTreeMap<K, V> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_table_from(self)?))
}
}
@@ -1007,9 +1006,9 @@ impl<'lua, K: Ord + FromLua<'lua>, V: FromLua<'lua>> FromLua<'lua> for BTreeMap<
}
}
-impl<'lua, T: Eq + Hash + IntoLua<'lua>, S: BuildHasher> IntoLua<'lua> for HashSet<T, S> {
+impl<T: Eq + Hash + IntoLua, S: BuildHasher> IntoLua for HashSet<T, S> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_table_from(
self.into_iter().map(|val| (val, true)),
)?))
@@ -1034,9 +1033,9 @@ impl<'lua, T: Eq + Hash + FromLua<'lua>, S: BuildHasher + Default> FromLua<'lua>
}
}
-impl<'lua, T: Ord + IntoLua<'lua>> IntoLua<'lua> for BTreeSet<T> {
+impl<T: Ord + IntoLua> IntoLua for BTreeSet<T> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
Ok(Value::Table(lua.create_table_from(
self.into_iter().map(|val| (val, true)),
)?))
@@ -1061,9 +1060,9 @@ impl<'lua, T: Ord + FromLua<'lua>> FromLua<'lua> for BTreeSet<T> {
}
}
-impl<'lua, T: IntoLua<'lua>> IntoLua<'lua> for Option<T> {
+impl<T: IntoLua> IntoLua for Option<T> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
match self {
Some(val) => val.into_lua(lua),
None => Ok(Nil),
@@ -1071,7 +1070,7 @@ impl<'lua, T: IntoLua<'lua>> IntoLua<'lua> for Option<T> {
}
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
match self {
Some(val) => val.push_into_stack(lua)?,
None => ffi::lua_pushnil(lua.state()),
diff --git a/src/function.rs b/src/function.rs
index 39b9fce..81a7cda 100644
--- a/src/function.rs
+++ b/src/function.rs
@@ -122,7 +122,7 @@ impl<'lua> Function<'lua> {
/// # Ok(())
/// # }
/// ```
- pub fn call<A: IntoLuaMulti<'lua>, R: FromLuaMulti<'lua>>(&self, args: A) -> Result<R> {
+ pub fn call<A: IntoLuaMulti, R: FromLuaMulti<'lua>>(&self, args: A) -> Result<R> {
let lua = self.0.lua;
let state = lua.state();
unsafe {
@@ -178,7 +178,7 @@ impl<'lua> Function<'lua> {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn call_async<A, R>(&self, args: A) -> impl Future<Output = Result<R>> + 'lua
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
let lua = self.0.lua;
@@ -217,7 +217,7 @@ impl<'lua> Function<'lua> {
/// # Ok(())
/// # }
/// ```
- pub fn bind<A: IntoLuaMulti<'lua>>(&self, args: A) -> Result<Function<'lua>> {
+ pub fn bind<A: IntoLuaMulti>(&self, args: A) -> Result<Function<'lua>> {
unsafe extern "C-unwind" fn args_wrapper_impl(state: *mut ffi::lua_State) -> c_int {
let nargs = ffi::lua_gettop(state);
let nbinds = ffi::lua_tointeger(state, ffi::lua_upvalueindex(1)) as c_int;
@@ -549,7 +549,7 @@ impl OwnedFunction {
#[inline]
pub fn call<'lua, A, R>(&'lua self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
self.to_ref().call(args)
@@ -564,7 +564,7 @@ impl OwnedFunction {
#[inline]
pub async fn call_async<'lua, A, R>(&'lua self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
self.to_ref().call_async(args).await
@@ -579,10 +579,10 @@ pub(crate) struct WrappedAsyncFunction<'lua>(pub(crate) AsyncCallback<'lua, 'sta
impl<'lua> Function<'lua> {
/// Wraps a Rust function or closure, returning an opaque type that implements [`IntoLua`] trait.
#[inline]
- pub fn wrap<A, R, F>(func: F) -> impl IntoLua<'lua>
+ pub fn wrap<A, R, F>(func: F) -> impl IntoLua
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
{
WrappedFunction(Box::new(move |lua, nargs| unsafe {
@@ -593,10 +593,10 @@ impl<'lua> Function<'lua> {
/// Wraps a Rust mutable closure, returning an opaque type that implements [`IntoLua`] trait.
#[inline]
- pub fn wrap_mut<A, R, F>(func: F) -> impl IntoLua<'lua>
+ pub fn wrap_mut<A, R, F>(func: F) -> impl IntoLua
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
{
let func = RefCell::new(func);
@@ -612,12 +612,12 @@ impl<'lua> Function<'lua> {
/// Wraps a Rust async function or closure, returning an opaque type that implements [`IntoLua`] trait.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
- pub fn wrap_async<A, R, F, FR>(func: F) -> impl IntoLua<'lua>
+ pub fn wrap_async<A, R, F, FR>(func: F) -> impl IntoLua
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
- FR: Future<Output = Result<R>> + 'lua,
+ FR: Future<Output = Result<R>> + 'static,
{
WrappedAsyncFunction(Box::new(move |lua, args| unsafe {
let args = match A::from_lua_args(args, 1, None, lua) {
@@ -630,18 +630,20 @@ impl<'lua> Function<'lua> {
}
}
-impl<'lua> IntoLua<'lua> for WrappedFunction<'lua> {
+impl IntoLua for WrappedFunction<'_> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
- lua.create_callback(self.0).map(Value::Function)
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
+ lua.create_callback(unsafe { mem::transmute(self.0) })
+ .map(Value::Function)
}
}
#[cfg(feature = "async")]
-impl<'lua> IntoLua<'lua> for WrappedAsyncFunction<'lua> {
+impl IntoLua for WrappedAsyncFunction<'_> {
#[inline]
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
- lua.create_async_callback(self.0).map(Value::Function)
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
+ lua.create_async_callback(unsafe { mem::transmute(self.0) })
+ .map(Value::Function)
}
}
diff --git a/src/lua.rs b/src/lua.rs
index f47c945..df34c25 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -712,7 +712,7 @@ impl Lua {
pub unsafe fn entrypoint<'lua, A, R, F>(self, state: *mut ffi::lua_State, func: F) -> c_int
where
A: FromLuaMulti<'lua>,
- R: IntoLua<'lua>,
+ R: IntoLua,
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
{
let extra = self.extra.get();
@@ -734,7 +734,7 @@ impl Lua {
#[cfg(not(tarpaulin_include))]
pub unsafe fn entrypoint1<'lua, R, F>(self, state: *mut ffi::lua_State, func: F) -> c_int
where
- R: IntoLua<'lua>,
+ R: IntoLua,
F: Fn(&'lua Lua) -> Result<R> + MaybeSend + 'static,
{
self.entrypoint(state, move |lua, _: ()| func(lua))
@@ -1436,8 +1436,8 @@ impl Lua {
/// Creates a table and fills it with values from an iterator.
pub fn create_table_from<'lua, K, V, I>(&'lua self, iter: I) -> Result<Table<'lua>>
where
- K: IntoLua<'lua>,
- V: IntoLua<'lua>,
+ K: IntoLua,
+ V: IntoLua,
I: IntoIterator<Item = (K, V)>,
{
let state = self.state();
@@ -1466,7 +1466,7 @@ impl Lua {
/// Creates a table from an iterator of values, using `1..` as the keys.
pub fn create_sequence_from<'lua, T, I>(&'lua self, iter: I) -> Result<Table<'lua>>
where
- T: IntoLua<'lua>,
+ T: IntoLua,
I: IntoIterator<Item = T>,
{
let state = self.state();
@@ -1541,7 +1541,7 @@ impl Lua {
pub fn create_function<'lua, A, R, F>(&'lua self, func: F) -> Result<Function<'lua>>
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
{
self.create_callback(Box::new(move |lua, nargs| unsafe {
@@ -1559,7 +1559,7 @@ impl Lua {
pub fn create_function_mut<'lua, A, R, F>(&'lua self, func: F) -> Result<Function<'lua>>
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
{
let func = RefCell::new(func);
@@ -1625,7 +1625,7 @@ impl Lua {
pub fn create_async_function<'lua, A, R, F, FR>(&'lua self, func: F) -> Result<Function<'lua>>
where
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
FR: Future<Output = Result<R>> + 'lua,
{
@@ -1998,7 +1998,7 @@ impl Lua {
}
/// Converts a value that implements `IntoLua` into a `Value` instance.
- pub fn pack<'lua, T: IntoLua<'lua>>(&'lua self, t: T) -> Result<Value<'lua>> {
+ pub fn pack<'lua, T: IntoLua>(&'lua self, t: T) -> Result<Value<'lua>> {
t.into_lua(self)
}
@@ -2008,7 +2008,7 @@ impl Lua {
}
/// Converts a value that implements `IntoLuaMulti` into a `MultiValue` instance.
- pub fn pack_multi<'lua, T: IntoLuaMulti<'lua>>(&'lua self, t: T) -> Result<MultiValue<'lua>> {
+ pub fn pack_multi<'lua, T: IntoLuaMulti>(&'lua self, t: T) -> Result<MultiValue<'lua>> {
t.into_lua_multi(self)
}
@@ -2026,7 +2026,7 @@ impl Lua {
/// state.
pub fn set_named_registry_value<'lua, T>(&'lua self, name: &str, t: T) -> Result<()>
where
- T: IntoLua<'lua>,
+ T: IntoLua,
{
let state = self.state();
unsafe {
@@ -2080,13 +2080,13 @@ impl Lua {
/// However, dropped [`RegistryKey`]s automatically reused to store new values.
///
/// [`RegistryKey`]: crate::RegistryKey
- pub fn create_registry_value<'lua, T: IntoLua<'lua>>(&'lua self, t: T) -> Result<RegistryKey> {
+ pub fn create_registry_value<T: IntoLua>(&self, t: T) -> Result<RegistryKey> {
let state = self.state();
unsafe {
let _sg = StackGuard::new(state);
check_stack(state, 4)?;
- self.push_value(&t)?;
+ self.push(t)?;
let unref_list = (*self.extra.get()).registry_unref_list.clone();
@@ -2166,7 +2166,7 @@ impl Lua {
/// See [`create_registry_value`] for more details.
///
/// [`create_registry_value`]: #method.create_registry_value
- pub fn replace_registry_value<'lua, T: IntoLua<'lua>>(
+ pub fn replace_registry_value<'lua, T: IntoLua>(
&'lua self,
key: &RegistryKey,
t: T,
@@ -2324,7 +2324,7 @@ impl Lua {
/// Uses 2 stack spaces, does not call checkstack.
#[doc(hidden)]
#[inline(always)]
- pub unsafe fn push<'lua>(&'lua self, value: impl IntoLua<'lua>) -> Result<()> {
+ pub unsafe fn push<'lua>(&'lua self, value: impl IntoLua) -> Result<()> {
value.push_into_stack(self)
}
diff --git a/src/multi.rs b/src/multi.rs
index c321078..00f9e62 100644
--- a/src/multi.rs
+++ b/src/multi.rs
@@ -1,3 +1,5 @@
+use std::iter::FromIterator;
+use std::mem::transmute;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_int;
use std::result::Result as StdResult;
@@ -9,9 +11,9 @@ use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, MultiValue, Nil
/// Result is convertible to `MultiValue` following the common Lua idiom of returning the result
/// on success, or in the case of an error, returning `nil` and an error message.
-impl<'lua, T: IntoLua<'lua>, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<T, E> {
+impl<T: IntoLua, E: IntoLua> IntoLuaMulti for StdResult<T, E> {
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
match self {
Ok(val) => (val,).into_lua_multi(lua),
Err(err) => (Nil, err).into_lua_multi(lua),
@@ -19,7 +21,7 @@ impl<'lua, T: IntoLua<'lua>, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<
}
#[inline]
- unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, lua: &Lua) -> Result<c_int> {
match self {
Ok(val) => (val,).push_into_stack_multi(lua),
Err(err) => (Nil, err).push_into_stack_multi(lua),
@@ -27,9 +29,9 @@ impl<'lua, T: IntoLua<'lua>, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<
}
}
-impl<'lua, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<(), E> {
+impl<E: IntoLua> IntoLuaMulti for StdResult<(), E> {
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
match self {
Ok(_) => Ok(MultiValue::new()),
Err(err) => (Nil, err).into_lua_multi(lua),
@@ -37,7 +39,7 @@ impl<'lua, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<(), E> {
}
#[inline]
- unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, lua: &Lua) -> Result<c_int> {
match self {
Ok(_) => Ok(0),
Err(err) => (Nil, err).push_into_stack_multi(lua),
@@ -45,16 +47,16 @@ impl<'lua, E: IntoLua<'lua>> IntoLuaMulti<'lua> for StdResult<(), E> {
}
}
-impl<'lua, T: IntoLua<'lua>> IntoLuaMulti<'lua> for T {
+impl<T: IntoLua> IntoLuaMulti for T {
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
let mut v = MultiValue::with_lua_and_capacity(lua, 1);
v.push_back(self.into_lua(lua)?);
Ok(v)
}
#[inline]
- unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, lua: &Lua) -> Result<c_int> {
self.push_into_stack(lua)?;
Ok(1)
}
@@ -98,10 +100,10 @@ impl<'lua, T: FromLua<'lua>> FromLuaMulti<'lua> for T {
}
}
-impl<'lua> IntoLuaMulti<'lua> for MultiValue<'lua> {
+impl IntoLuaMulti for MultiValue<'_> {
#[inline]
- fn into_lua_multi(self, _: &'lua Lua) -> Result<MultiValue<'lua>> {
- Ok(self)
+ fn into_lua_multi(self, _: &Lua) -> Result<MultiValue<'_>> {
+ unsafe { Ok(transmute(self)) }
}
}
@@ -183,9 +185,9 @@ impl<T> DerefMut for Variadic<T> {
}
}
-impl<'lua, T: IntoLua<'lua>> IntoLuaMulti<'lua> for Variadic<T> {
+impl<T: IntoLua> IntoLuaMulti for Variadic<T> {
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
let mut values = MultiValue::with_lua_and_capacity(lua, self.0.len());
values.extend_from_values(self.0.into_iter().map(|val| val.into_lua(lua)))?;
Ok(values)
@@ -205,14 +207,14 @@ impl<'lua, T: FromLua<'lua>> FromLuaMulti<'lua> for Variadic<T> {
macro_rules! impl_tuple {
() => (
- impl<'lua> IntoLuaMulti<'lua> for () {
+ impl IntoLuaMulti for () {
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
Ok(MultiValue::with_lua_and_capacity(lua, 0))
}
#[inline]
- unsafe fn push_into_stack_multi(self, _lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, _lua: &Lua) -> Result<c_int> {
Ok(0)
}
}
@@ -234,13 +236,13 @@ macro_rules! impl_tuple {
);
($last:ident $($name:ident)*) => (
- impl<'lua, $($name,)* $last> IntoLuaMulti<'lua> for ($($name,)* $last,)
- where $($name: IntoLua<'lua>,)*
- $last: IntoLuaMulti<'lua>
+ impl<$($name,)* $last> IntoLuaMulti for ($($name,)* $last,)
+ where $($name: IntoLua,)*
+ $last: IntoLuaMulti
{
#[allow(unused_mut, non_snake_case)]
#[inline]
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>> {
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>> {
let ($($name,)* $last,) = self;
let mut results = $last.into_lua_multi(lua)?;
@@ -250,7 +252,7 @@ macro_rules! impl_tuple {
#[allow(non_snake_case)]
#[inline]
- unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, lua: &Lua) -> Result<c_int> {
let ($($name,)* $last,) = self;
let mut nresults = 0;
$(
diff --git a/src/scope.rs b/src/scope.rs
index fddbf36..25678c9 100644
--- a/src/scope.rs
+++ b/src/scope.rs
@@ -63,7 +63,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
pub fn create_function<'callback, A, R, F>(&'callback self, func: F) -> Result<Function<'lua>>
where
A: FromLuaMulti<'callback>,
- R: IntoLuaMulti<'callback>,
+ R: IntoLuaMulti,
F: Fn(&'callback Lua, A) -> Result<R> + 'scope,
{
// Safe, because 'scope must outlive 'callback (due to Self containing 'scope), however the
@@ -97,7 +97,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
) -> Result<Function<'lua>>
where
A: FromLuaMulti<'callback>,
- R: IntoLuaMulti<'callback>,
+ R: IntoLuaMulti,
F: FnMut(&'callback Lua, A) -> Result<R> + 'scope,
{
let func = RefCell::new(func);
@@ -656,7 +656,7 @@ impl<'lua, T> NonStaticUserDataRegistry<'lua, T> {
impl<'lua, T> UserDataFields<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
fn add_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static,
+ V: IntoLua + Clone + 'static,
{
let name = name.as_ref().to_string();
self.fields.push((
@@ -670,7 +670,7 @@ impl<'lua, T> UserDataFields<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
fn add_field_method_get<M, R>(&mut self, name: impl AsRef<str>, method: M)
where
M: Fn(&'lua Lua, &T) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let method = NonStaticMethod::Method(Box::new(move |lua, ud, _| unsafe {
method(lua, ud)?.push_into_stack_multi(lua)
@@ -694,7 +694,7 @@ impl<'lua, T> UserDataFields<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
fn add_field_function_get<F, R>(&mut self, name: impl AsRef<str>, function: F)
where
F: Fn(&'lua Lua, AnyUserData<'lua>) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let func = NonStaticMethod::Function(Box::new(move |lua, nargs| unsafe {
@@ -719,7 +719,7 @@ impl<'lua, T> UserDataFields<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
fn add_meta_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static,
+ V: IntoLua + Clone + 'static,
{
let name = name.as_ref().to_string();
let name2 = name.clone();
@@ -735,7 +735,7 @@ impl<'lua, T> UserDataFields<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
fn add_meta_field_with<F, R>(&mut self, name: impl AsRef<str>, f: F)
where
F: Fn(&'lua Lua) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let name = name.as_ref().to_string();
let name2 = name.clone();
@@ -754,7 +754,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let method = NonStaticMethod::Method(Box::new(move |lua, ud, nargs| unsafe {
@@ -768,7 +768,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let method = NonStaticMethod::MethodMut(Box::new(move |lua, ud, nargs| unsafe {
@@ -786,7 +786,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
@@ -801,7 +801,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
@@ -812,7 +812,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let func = NonStaticMethod::Function(Box::new(move |lua, nargs| unsafe {
@@ -826,7 +826,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let func = NonStaticMethod::FunctionMut(Box::new(move |lua, nargs| unsafe {
@@ -842,7 +842,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
@@ -853,7 +853,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let method = NonStaticMethod::Method(Box::new(move |lua, ud, nargs| unsafe {
@@ -867,7 +867,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let method = NonStaticMethod::MethodMut(Box::new(move |lua, ud, nargs| unsafe {
@@ -885,7 +885,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
@@ -900,7 +900,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
@@ -911,7 +911,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let func = NonStaticMethod::Function(Box::new(move |lua, nargs| unsafe {
@@ -925,7 +925,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let func_name = format!("{}.{}", short_type_name::<T>(), name.as_ref());
let func = NonStaticMethod::FunctionMut(Box::new(move |lua, nargs| unsafe {
@@ -941,7 +941,7 @@ impl<'lua, T> UserDataMethods<'lua, T> for NonStaticUserDataRegistry<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
// The panic should never happen as async non-static code wouldn't compile
// Non-static lifetime must be bounded to 'lua lifetime
diff --git a/src/table.rs b/src/table.rs
index 43b942e..9eca8d5 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -79,7 +79,7 @@ impl<'lua> Table<'lua> {
/// ```
///
/// [`raw_set`]: #method.raw_set
- pub fn set<K: IntoLua<'lua>, V: IntoLua<'lua>>(&self, key: K, value: V) -> Result<()> {
+ pub fn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()> {
// Fast track
if !self.has_metatable() {
return self.raw_set(key, value);
@@ -122,7 +122,7 @@ impl<'lua> Table<'lua> {
/// ```
///
/// [`raw_get`]: #method.raw_get
- pub fn get<K: IntoLua<'lua>, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
+ pub fn get<K: IntoLua, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
// Fast track
if !self.has_metatable() {
return self.raw_get(key);
@@ -145,14 +145,14 @@ impl<'lua> Table<'lua> {
/// Checks whether the table contains a non-nil value for `key`.
///
/// This might invoke the `__index` metamethod.
- pub fn contains_key<K: IntoLua<'lua>>(&self, key: K) -> Result<bool> {
+ pub fn contains_key<K: IntoLua>(&self, key: K) -> Result<bool> {
Ok(self.get::<_, Value>(key)? != Value::Nil)
}
/// Appends a value to the back of the table.
///
/// This might invoke the `__len` and `__newindex` metamethods.
- pub fn push<V: IntoLua<'lua>>(&self, value: V) -> Result<()> {
+ pub fn push<V: IntoLua>(&self, value: V) -> Result<()> {
// Fast track
if !self.has_metatable() {
return self.raw_push(value);
@@ -253,7 +253,7 @@ impl<'lua> Table<'lua> {
}
/// Sets a key-value pair without invoking metamethods.
- pub fn raw_set<K: IntoLua<'lua>, V: IntoLua<'lua>>(&self, key: K, value: V) -> Result<()> {
+ pub fn raw_set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()> {
#[cfg(feature = "luau")]
self.check_readonly_write()?;
@@ -278,7 +278,7 @@ impl<'lua> Table<'lua> {
}
/// Gets the value associated to `key` without invoking metamethods.
- pub fn raw_get<K: IntoLua<'lua>, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
+ pub fn raw_get<K: IntoLua, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
let lua = self.0.lua;
let state = lua.state();
unsafe {
@@ -295,7 +295,7 @@ impl<'lua> Table<'lua> {
/// Inserts element value at position `idx` to the table, shifting up the elements from `table[idx]`.
/// The worst case complexity is O(n), where n is the table length.
- pub fn raw_insert<V: IntoLua<'lua>>(&self, idx: Integer, value: V) -> Result<()> {
+ pub fn raw_insert<V: IntoLua>(&self, idx: Integer, value: V) -> Result<()> {
let size = self.raw_len() as Integer;
if idx < 1 || idx > size + 1 {
return Err(Error::runtime("index out of bounds"));
@@ -321,7 +321,7 @@ impl<'lua> Table<'lua> {
}
/// Appends a value to the back of the table without invoking metamethods.
- pub fn raw_push<V: IntoLua<'lua>>(&self, value: V) -> Result<()> {
+ pub fn raw_push<V: IntoLua>(&self, value: V) -> Result<()> {
#[cfg(feature = "luau")]
self.check_readonly_write()?;
@@ -377,7 +377,7 @@ impl<'lua> Table<'lua> {
/// where n is the table length.
///
/// For other key types this is equivalent to setting `table[key] = nil`.
- pub fn raw_remove<K: IntoLua<'lua>>(&self, key: K) -> Result<()> {
+ pub fn raw_remove<K: IntoLua>(&self, key: K) -> Result<()> {
let lua = self.0.lua;
let state = lua.state();
let key = key.into_lua(lua)?;
@@ -751,7 +751,7 @@ impl<'lua> Table<'lua> {
/// Sets element value at position `idx` without invoking metamethods.
#[doc(hidden)]
- pub fn raw_seti<V: IntoLua<'lua>>(&self, idx: usize, value: V) -> Result<()> {
+ pub fn raw_seti<V: IntoLua>(&self, idx: usize, value: V) -> Result<()> {
#[cfg(feature = "luau")]
self.check_readonly_write()?;
@@ -852,7 +852,7 @@ impl<'lua> AsRef<Table<'lua>> for Table<'lua> {
impl<'lua, T> PartialEq<[T]> for Table<'lua>
where
- T: IntoLua<'lua> + Clone,
+ T: IntoLua + Clone,
{
fn eq(&self, other: &[T]) -> bool {
let lua = self.0.lua;
@@ -882,7 +882,7 @@ where
impl<'lua, T> PartialEq<&[T]> for Table<'lua>
where
- T: IntoLua<'lua> + Clone,
+ T: IntoLua + Clone,
{
#[inline]
fn eq(&self, other: &&[T]) -> bool {
@@ -892,7 +892,7 @@ where
impl<'lua, T, const N: usize> PartialEq<[T; N]> for Table<'lua>
where
- T: IntoLua<'lua> + Clone,
+ T: IntoLua + Clone,
{
#[inline]
fn eq(&self, other: &[T; N]) -> bool {
@@ -907,7 +907,7 @@ pub trait TableExt<'lua>: Sealed {
/// The metamethod is called with the table as its first argument, followed by the passed arguments.
fn call<A, R>(&self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Asynchronously calls the table as function assuming it has `__call` metamethod.
@@ -917,7 +917,7 @@ pub trait TableExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async<A, R>(&self, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
/// Gets the function associated to `key` from the table and executes it,
@@ -929,7 +929,7 @@ pub trait TableExt<'lua>: Sealed {
/// This might invoke the `__index` metamethod.
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Gets the function associated to `key` from the table and executes it,
@@ -941,7 +941,7 @@ pub trait TableExt<'lua>: Sealed {
/// This might invoke the `__index` metamethod.
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Gets the function associated to `key` from the table and asynchronously executes it,
@@ -954,7 +954,7 @@ pub trait TableExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async_method<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
/// Gets the function associated to `key` from the table and asynchronously executes it,
@@ -967,14 +967,14 @@ pub trait TableExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async_function<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
}
impl<'lua> TableExt<'lua> for Table<'lua> {
fn call<A, R>(&self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
// Convert table to a function and call via pcall that respects the `__call` metamethod.
@@ -984,7 +984,7 @@ impl<'lua> TableExt<'lua> for Table<'lua> {
#[cfg(feature = "async")]
fn call_async<A, R>(&self, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
let args = match args.into_lua_multi(self.0.lua) {
@@ -997,7 +997,7 @@ impl<'lua> TableExt<'lua> for Table<'lua> {
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
self.get::<_, Function>(name)?.call((self, args))
@@ -1005,7 +1005,7 @@ impl<'lua> TableExt<'lua> for Table<'lua> {
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
self.get::<_, Function>(name)?.call(args)
@@ -1014,7 +1014,7 @@ impl<'lua> TableExt<'lua> for Table<'lua> {
#[cfg(feature = "async")]
fn call_async_method<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
self.call_async_function(name, (self, args))
@@ -1023,7 +1023,7 @@ impl<'lua> TableExt<'lua> for Table<'lua> {
#[cfg(feature = "async")]
fn call_async_function<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
let lua = self.0.lua;
diff --git a/src/thread.rs b/src/thread.rs
index f90daba..489416f 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -139,7 +139,7 @@ impl<'lua> Thread<'lua> {
/// ```
pub fn resume<A, R>(&self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
if self.status() != ThreadStatus::Resumable {
@@ -164,7 +164,7 @@ impl<'lua> Thread<'lua> {
/// Resumes execution of this thread.
///
/// It's similar to `resume()` but leaves `nresults` values on the thread stack.
- unsafe fn resume_inner<A: IntoLuaMulti<'lua>>(&self, args: A) -> Result<c_int> {
+ unsafe fn resume_inner<A: IntoLuaMulti>(&self, args: A) -> Result<c_int> {
let lua = self.0.lua;
let state = lua.state();
let thread_state = self.state();
@@ -325,7 +325,7 @@ impl<'lua> Thread<'lua> {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn into_async<A, R>(self, args: A) -> AsyncThread<'lua, R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
let args = args.into_lua_multi(self.0.lua);
@@ -415,7 +415,7 @@ impl OwnedThread {
/// See [`Thread::resume()`] for more details.
pub fn resume<'lua, A, R>(&'lua self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
self.to_ref().resume(args)
diff --git a/src/userdata.rs b/src/userdata.rs
index d7858e1..408333b 100644
--- a/src/userdata.rs
+++ b/src/userdata.rs
@@ -266,7 +266,7 @@ pub trait UserDataMethods<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a regular method which accepts a `&mut T` as the first parameter.
///
@@ -277,7 +277,7 @@ pub trait UserDataMethods<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add an async method which accepts a `&T` as the first parameter and returns Future.
///
@@ -295,7 +295,7 @@ pub trait UserDataMethods<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add an async method which accepts a `&mut T` as the first parameter and returns Future.
///
@@ -313,7 +313,7 @@ pub trait UserDataMethods<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a regular method as a function which accepts generic arguments, the first argument will
/// be a [`AnyUserData`] of type `T` if the method is called with Lua method syntax:
@@ -329,7 +329,7 @@ pub trait UserDataMethods<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a regular method as a mutable function which accepts generic arguments.
///
@@ -340,7 +340,7 @@ pub trait UserDataMethods<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a regular method as an async function which accepts generic arguments
/// and returns Future.
@@ -357,7 +357,7 @@ pub trait UserDataMethods<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a metamethod which accepts a `&T` as the first parameter.
///
@@ -371,7 +371,7 @@ pub trait UserDataMethods<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a metamethod as a function which accepts a `&mut T` as the first parameter.
///
@@ -385,7 +385,7 @@ pub trait UserDataMethods<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add an async metamethod which accepts a `&T` as the first parameter and returns Future.
///
@@ -403,7 +403,7 @@ pub trait UserDataMethods<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add an async metamethod which accepts a `&mut T` as the first parameter and returns Future.
///
@@ -421,7 +421,7 @@ pub trait UserDataMethods<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a metamethod which accepts generic arguments.
///
@@ -432,7 +432,7 @@ pub trait UserDataMethods<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a metamethod as a mutable function which accepts generic arguments.
///
@@ -443,7 +443,7 @@ pub trait UserDataMethods<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
/// Add a metamethod which accepts generic arguments and returns Future.
///
@@ -459,7 +459,7 @@ pub trait UserDataMethods<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>;
+ R: IntoLuaMulti;
//
// Below are internal methods used in generated code
@@ -484,7 +484,7 @@ pub trait UserDataFields<'lua, T> {
/// be used as a fall-back if no regular field or method are found.
fn add_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static;
+ V: IntoLua + Clone + 'static;
/// Add a regular field getter as a method which accepts a `&T` as the parameter.
///
@@ -496,7 +496,7 @@ pub trait UserDataFields<'lua, T> {
fn add_field_method_get<M, R>(&mut self, name: impl AsRef<str>, method: M)
where
M: Fn(&'lua Lua, &T) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>;
+ R: IntoLua;
/// Add a regular field setter as a method which accepts a `&mut T` as the first parameter.
///
@@ -520,7 +520,7 @@ pub trait UserDataFields<'lua, T> {
fn add_field_function_get<F, R>(&mut self, name: impl AsRef<str>, function: F)
where
F: Fn(&'lua Lua, AnyUserData<'lua>) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>;
+ R: IntoLua;
/// Add a regular field setter as a function which accepts a generic [`AnyUserData`] of type `T`
/// first argument.
@@ -544,7 +544,7 @@ pub trait UserDataFields<'lua, T> {
/// like `__gc` or `__metatable`.
fn add_meta_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static;
+ V: IntoLua + Clone + 'static;
/// Add a metatable field computed from `f`.
///
@@ -557,7 +557,7 @@ pub trait UserDataFields<'lua, T> {
fn add_meta_field_with<F, R>(&mut self, name: impl AsRef<str>, f: F)
where
F: Fn(&'lua Lua) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>;
+ R: IntoLua;
//
// Below are internal methods used in generated code
@@ -872,7 +872,7 @@ impl<'lua> AnyUserData<'lua> {
/// [`user_value`]: #method.user_value
/// [`set_nth_user_value`]: #method.set_nth_user_value
#[inline]
- pub fn set_user_value<V: IntoLua<'lua>>(&self, v: V) -> Result<()> {
+ pub fn set_user_value<V: IntoLua>(&self, v: V) -> Result<()> {
self.set_nth_user_value(1, v)
}
@@ -903,7 +903,7 @@ impl<'lua> AnyUserData<'lua> {
/// For other Lua versions this functionality is provided using a wrapping table.
///
/// [`nth_user_value`]: #method.nth_user_value
- pub fn set_nth_user_value<V: IntoLua<'lua>>(&self, n: usize, v: V) -> Result<()> {
+ pub fn set_nth_user_value<V: IntoLua>(&self, n: usize, v: V) -> Result<()> {
if n < 1 || n > u16::MAX as usize {
return Err(Error::runtime("user value index out of bounds"));
}
@@ -1002,7 +1002,7 @@ impl<'lua> AnyUserData<'lua> {
/// The value can be retrieved with [`named_user_value`].
///
/// [`named_user_value`]: #method.named_user_value
- pub fn set_named_user_value<V: IntoLua<'lua>>(&self, name: &str, v: V) -> Result<()> {
+ pub fn set_named_user_value<V: IntoLua>(&self, name: &str, v: V) -> Result<()> {
let lua = self.0.lua;
let state = lua.state();
unsafe {
@@ -1276,7 +1276,7 @@ impl<'lua> UserDataMetatable<'lua> {
/// Access to restricted metamethods such as `__gc` or `__metatable` will cause an error.
/// Setting `__index` or `__newindex` metamethods is also restricted because their values are cached
/// for `mlua` internal usage.
- pub fn set<V: IntoLua<'lua>>(&self, key: impl AsRef<str>, value: V) -> Result<()> {
+ pub fn set<V: IntoLua>(&self, key: impl AsRef<str>, value: V) -> Result<()> {
let key = MetaMethod::validate(key.as_ref())?;
// `__index` and `__newindex` cannot be changed in runtime, because values are cached
if key == MetaMethod::Index || key == MetaMethod::NewIndex {
@@ -1422,16 +1422,16 @@ impl<'lua> AnyUserData<'lua> {
/// Wraps any Rust type, returning an opaque type that implements [`IntoLua`] trait.
///
/// This function uses [`Lua::create_any_userdata()`] under the hood.
- pub fn wrap<T: MaybeSend + 'static>(data: T) -> impl IntoLua<'lua> {
+ pub fn wrap<T: MaybeSend + 'static>(data: T) -> impl IntoLua {
WrappedUserdata(move |lua| lua.create_any_userdata(data))
}
}
-impl<'lua, F> IntoLua<'lua> for WrappedUserdata<F>
+impl<F> IntoLua for WrappedUserdata<F>
where
F: for<'l> FnOnce(&'l Lua) -> Result<AnyUserData<'l>>,
{
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>> {
(self.0)(lua).map(Value::UserData)
}
}
diff --git a/src/userdata_ext.rs b/src/userdata_ext.rs
index 71c36f9..268324d 100644
--- a/src/userdata_ext.rs
+++ b/src/userdata_ext.rs
@@ -9,17 +9,17 @@ use futures_util::future::{self, LocalBoxFuture};
/// An extension trait for [`AnyUserData`] that provides a variety of convenient functionality.
pub trait AnyUserDataExt<'lua>: Sealed {
/// Gets the value associated to `key` from the userdata, assuming it has `__index` metamethod.
- fn get<K: IntoLua<'lua>, V: FromLua<'lua>>(&self, key: K) -> Result<V>;
+ fn get<K: IntoLua, V: FromLua<'lua>>(&self, key: K) -> Result<V>;
/// Sets the value associated to `key` in the userdata, assuming it has `__newindex` metamethod.
- fn set<K: IntoLua<'lua>, V: IntoLua<'lua>>(&self, key: K, value: V) -> Result<()>;
+ fn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()>;
/// Calls the userdata as a function assuming it has `__call` metamethod.
///
/// The metamethod is called with the userdata as its first argument, followed by the passed arguments.
fn call<A, R>(&self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Asynchronously calls the userdata as a function assuming it has `__call` metamethod.
@@ -29,14 +29,14 @@ pub trait AnyUserDataExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async<A, R>(&self, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
/// Calls the userdata method, assuming it has `__index` metamethod
/// and a function associated to `name`.
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Gets the function associated to `key` from the table and asynchronously executes it,
@@ -49,7 +49,7 @@ pub trait AnyUserDataExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async_method<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
/// Gets the function associated to `key` from the table and executes it,
@@ -61,7 +61,7 @@ pub trait AnyUserDataExt<'lua>: Sealed {
/// This might invoke the `__index` metamethod.
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>;
/// Gets the function associated to `key` from the table and asynchronously executes it,
@@ -74,12 +74,12 @@ pub trait AnyUserDataExt<'lua>: Sealed {
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
fn call_async_function<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua;
}
impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
- fn get<K: IntoLua<'lua>, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
+ fn get<K: IntoLua, V: FromLua<'lua>>(&self, key: K) -> Result<V> {
let metatable = self.get_metatable()?;
match metatable.get::<Value>(MetaMethod::Index)? {
Value::Table(table) => table.raw_get(key),
@@ -88,7 +88,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
}
}
- fn set<K: IntoLua<'lua>, V: IntoLua<'lua>>(&self, key: K, value: V) -> Result<()> {
+ fn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()> {
let metatable = self.get_metatable()?;
match metatable.get::<Value>(MetaMethod::NewIndex)? {
Value::Table(table) => table.raw_set(key, value),
@@ -99,7 +99,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
fn call<A, R>(&self, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
let metatable = self.get_metatable()?;
@@ -112,7 +112,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
#[cfg(feature = "async")]
fn call_async<A, R>(&self, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
let metatable = match self.get_metatable() {
@@ -136,7 +136,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
self.call_function(name, (self, args))
@@ -145,7 +145,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
#[cfg(feature = "async")]
fn call_async_method<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
self.call_async_function(name, (self, args))
@@ -153,7 +153,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua>,
{
match self.get(name)? {
@@ -168,7 +168,7 @@ impl<'lua> AnyUserDataExt<'lua> for AnyUserData<'lua> {
#[cfg(feature = "async")]
fn call_async_function<A, R>(&self, name: &str, args: A) -> LocalBoxFuture<'lua, Result<R>>
where
- A: IntoLuaMulti<'lua>,
+ A: IntoLuaMulti,
R: FromLuaMulti<'lua> + 'lua,
{
match self.get(name) {
diff --git a/src/userdata_impl.rs b/src/userdata_impl.rs
index 9780758..b3acd48 100644
--- a/src/userdata_impl.rs
+++ b/src/userdata_impl.rs
@@ -62,7 +62,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = get_function_name::<T>(name);
macro_rules! try_self_arg {
@@ -138,7 +138,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = get_function_name::<T>(name);
macro_rules! try_self_arg {
@@ -216,7 +216,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = Arc::new(get_function_name::<T>(name));
let method = Arc::new(method);
@@ -310,7 +310,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = Arc::new(get_function_name::<T>(name));
let method = Arc::new(method);
@@ -398,7 +398,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = get_function_name::<T>(name);
Box::new(move |lua, nargs| unsafe {
@@ -411,7 +411,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = get_function_name::<T>(name);
let function = RefCell::new(function);
@@ -430,7 +430,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = get_function_name::<T>(name);
Box::new(move |lua, args| unsafe {
@@ -445,7 +445,7 @@ impl<'lua, T: 'static> UserDataRegistry<'lua, T> {
pub(crate) fn check_meta_field<V>(lua: &'lua Lua, name: &str, value: V) -> Result<Value<'lua>>
where
- V: IntoLua<'lua>,
+ V: IntoLua,
{
let value = value.into_lua(lua)?;
if name == MetaMethod::Index || name == MetaMethod::NewIndex {
@@ -472,7 +472,7 @@ fn get_function_name<T>(name: &str) -> StdString {
impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T> {
fn add_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static,
+ V: IntoLua + Clone + 'static,
{
let name = name.as_ref().to_string();
self.fields.push((
@@ -484,7 +484,7 @@ impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T> {
fn add_field_method_get<M, R>(&mut self, name: impl AsRef<str>, method: M)
where
M: Fn(&'lua Lua, &T) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let name = name.as_ref();
let method = Self::box_method(name, move |lua, data, ()| method(lua, data));
@@ -504,7 +504,7 @@ impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T> {
fn add_field_function_get<F, R>(&mut self, name: impl AsRef<str>, function: F)
where
F: Fn(&'lua Lua, AnyUserData<'lua>) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let name = name.as_ref();
let func = Self::box_function(name, function);
@@ -523,7 +523,7 @@ impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T> {
fn add_meta_field<V>(&mut self, name: impl AsRef<str>, value: V)
where
- V: IntoLua<'lua> + Clone + 'static,
+ V: IntoLua + Clone + 'static,
{
let name = name.as_ref().to_string();
let name2 = name.clone();
@@ -538,7 +538,7 @@ impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T> {
fn add_meta_field_with<F, R>(&mut self, name: impl AsRef<str>, f: F)
where
F: Fn(&'lua Lua) -> Result<R> + MaybeSend + 'static,
- R: IntoLua<'lua>,
+ R: IntoLua,
{
let name = name.as_ref().to_string();
let name2 = name.clone();
@@ -565,7 +565,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.methods
@@ -576,7 +576,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.methods
@@ -591,7 +591,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_methods
@@ -606,7 +606,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_methods
@@ -617,7 +617,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.methods
@@ -628,7 +628,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.methods
@@ -641,7 +641,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_methods
@@ -652,7 +652,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.meta_methods
@@ -663,7 +663,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.meta_methods
@@ -678,7 +678,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_meta_methods
@@ -693,7 +693,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
MR: Future<Output = Result<R>> + 's,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_meta_methods
@@ -704,7 +704,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.meta_methods
@@ -715,7 +715,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
where
F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.meta_methods
@@ -728,7 +728,7 @@ impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T> {
F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static,
A: FromLuaMulti<'lua>,
FR: Future<Output = Result<R>> + 'lua,
- R: IntoLuaMulti<'lua>,
+ R: IntoLuaMulti,
{
let name = name.as_ref();
self.async_meta_methods
diff --git a/src/value.rs b/src/value.rs
index 8ebfc42..2e5f2d9 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -687,9 +687,9 @@ impl<'a, 'lua> Serialize for SerializableValue<'a, 'lua> {
}
/// Trait for types convertible to `Value`.
-pub trait IntoLua<'lua>: Sized {
+pub trait IntoLua: Sized {
/// Performs the conversion.
- fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>>;
+ fn into_lua(self, lua: &Lua) -> Result<Value<'_>>;
/// Pushes the value into the Lua stack.
///
@@ -697,7 +697,7 @@ pub trait IntoLua<'lua>: Sized {
/// This method does not check Lua stack space.
#[doc(hidden)]
#[inline]
- unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
+ unsafe fn push_into_stack(self, lua: &Lua) -> Result<()> {
lua.push_value(&self.into_lua(lua)?)
}
}
@@ -859,16 +859,16 @@ impl<'a, 'lua> IntoIterator for &'a MultiValue<'lua> {
///
/// This is a generalization of `IntoLua`, allowing any number of resulting Lua values instead of just
/// one. Any type that implements `IntoLua` will automatically implement this trait.
-pub trait IntoLuaMulti<'lua>: Sized {
+pub trait IntoLuaMulti: Sized {
/// Performs the conversion.
- fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>>;
+ fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue<'_>>;
/// Pushes the values into the Lua stack.
///
/// Returns number of pushed values.
#[doc(hidden)]
#[inline]
- unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<c_int> {
+ unsafe fn push_into_stack_multi(self, lua: &Lua) -> Result<c_int> {
let values = self.into_lua_multi(lua)?;
let len: c_int = values.len().try_into().unwrap();
unsafe {