Refactor call_async() functions to use static dispatch outside of traits

This commit is contained in:
Alex Orlenko
2023-06-21 12:44:24 +01:00
parent b05698d55b
commit c1168d3ec1
5 changed files with 87 additions and 88 deletions
+3 -2
View File
@@ -58,7 +58,7 @@ use crate::{
#[cfg(feature = "async")]
use {
crate::types::{AsyncCallback, AsyncCallbackUpvalue, AsyncPollUpvalue},
futures_util::future::{self, Future, TryFutureExt},
futures_util::future::{self, Future},
futures_util::task::{noop_waker_ref, Context, Poll, Waker},
};
@@ -1619,7 +1619,8 @@ impl Lua {
Ok(args) => args,
Err(e) => return Box::pin(future::err(e)),
};
Box::pin(func(lua, args).and_then(move |ret| future::ready(ret.into_lua_multi(lua))))
let fut = func(lua, args);
Box::pin(async move { fut.await?.into_lua_multi(lua) })
}))
}