@@ -137,13 +137,6 @@ impl LuaOptions {
137
137
}
138
138
}
139
139
140
- #[ cfg( not( feature = "module" ) ) ]
141
- impl Drop for Lua {
142
- fn drop ( & mut self ) {
143
- let _ = self . gc_collect ( ) ;
144
- }
145
- }
146
-
147
140
impl fmt:: Debug for Lua {
148
141
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
149
142
write ! ( f, "Lua({:p})" , self . lock( ) . state( ) )
@@ -1138,7 +1131,7 @@ impl Lua {
1138
1131
/// use std::time::Duration;
1139
1132
/// use mlua::{Lua, Result};
1140
1133
///
1141
- /// async fn sleep(_lua: & Lua, n: u64) -> Result<&'static str> {
1134
+ /// async fn sleep(_lua: Lua, n: u64) -> Result<&'static str> {
1142
1135
/// tokio::time::sleep(Duration::from_millis(n)).await;
1143
1136
/// Ok("done")
1144
1137
/// }
@@ -1157,20 +1150,20 @@ impl Lua {
1157
1150
/// [`AsyncThread`]: crate::AsyncThread
1158
1151
#[ cfg( feature = "async" ) ]
1159
1152
#[ cfg_attr( docsrs, doc( cfg( feature = "async" ) ) ) ]
1160
- pub fn create_async_function < ' lua , ' a , F , A , FR , R > ( & ' lua self , func : F ) -> Result < Function >
1153
+ pub fn create_async_function < F , A , FR , R > ( & self , func : F ) -> Result < Function >
1161
1154
where
1162
- ' lua : ' a ,
1163
- F : Fn ( & ' a Lua , A ) -> FR + MaybeSend + ' static ,
1155
+ F : Fn ( Lua , A ) -> FR + MaybeSend + ' static ,
1164
1156
A : FromLuaMulti ,
1165
- FR : Future < Output = Result < R > > + MaybeSend + ' a ,
1157
+ FR : Future < Output = Result < R > > + MaybeSend + ' static ,
1166
1158
R : IntoLuaMulti ,
1167
1159
{
1168
- ( self . lock ( ) ) . create_async_callback ( Box :: new ( move |lua , args | unsafe {
1169
- let args = match A :: from_lua_args ( args , 1 , None , lua ) {
1160
+ ( self . lock ( ) ) . create_async_callback ( Box :: new ( move |rawlua , nargs | unsafe {
1161
+ let args = match A :: from_stack_args ( nargs , 1 , None , rawlua ) {
1170
1162
Ok ( args) => args,
1171
1163
Err ( e) => return Box :: pin ( future:: ready ( Err ( e) ) ) ,
1172
1164
} ;
1173
- let fut = func ( lua, args) ;
1165
+ let lua = rawlua. lua ( ) . clone ( ) ;
1166
+ let fut = func ( lua. clone ( ) , args) ;
1174
1167
Box :: pin ( async move { fut. await ?. push_into_stack_multi ( lua. raw_lua ( ) ) } )
1175
1168
} ) )
1176
1169
}
@@ -1274,11 +1267,11 @@ impl Lua {
1274
1267
/// struct MyUserData(i32);
1275
1268
///
1276
1269
/// impl UserData for MyUserData {
1277
- /// fn add_fields<'a, F: UserDataFields<'a, Self>>(fields: &mut F) {
1270
+ /// fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
1278
1271
/// fields.add_field_method_get("val", |_, this| Ok(this.0));
1279
1272
/// }
1280
1273
///
1281
- /// fn add_methods<'a, M: UserDataMethods<'a, Self>>(methods: &mut M) {
1274
+ /// fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
1282
1275
/// methods.add_function("new", |_, value: i32| Ok(MyUserData(value)));
1283
1276
/// }
1284
1277
/// }
0 commit comments