Fix "unused" warning in tests

This commit is contained in:
Alex Orlenko 2022-04-17 22:39:21 +01:00
parent a62636fde0
commit 790df77965
No known key found for this signature in database
GPG key ID: 4C150C250863B96D

View file

@ -1,6 +1,6 @@
use std::cell::RefCell;
use mlua::{Function, Lua, Result, Table};
use mlua::{Lua, Result, Table};
#[test]
fn test_static_lua() -> Result<()> {
@ -73,16 +73,17 @@ fn test_static_lua_coroutine() -> Result<()> {
async fn test_static_async() -> Result<()> {
let lua = Lua::new().into_static();
let timer = lua.create_async_function(|_, (i, n, f): (u64, u64, Function)| async move {
tokio::task::spawn_local(async move {
let dur = std::time::Duration::from_millis(i);
for _ in 0..n {
tokio::task::spawn_local(f.call_async::<(), ()>(()));
tokio::time::sleep(dur).await;
}
});
Ok(())
})?;
let timer =
lua.create_async_function(|_, (i, n, f): (u64, u64, mlua::Function)| async move {
tokio::task::spawn_local(async move {
let dur = std::time::Duration::from_millis(i);
for _ in 0..n {
tokio::task::spawn_local(f.call_async::<(), ()>(()));
tokio::time::sleep(dur).await;
}
});
Ok(())
})?;
lua.globals().set("timer", timer)?;
{