You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to iterate over a table with functions unsuccessfully. I am not very experienced in Rust so I do not understand the compiler error. Here is my code:
letmut lua = lua::Lua::new();
lua.execute::<()>("table = { a = function (x) return x end }");letmut fns:Vec<lua::LuaFunction<_>> = Vec::new();letmut table_lua = lua.get::<lua::LuaTable<_>,_>("table").expect("reading table");letmut table_lua_iter = table_lua.iter::<lua::AnyLuaValue, lua::LuaFunction<_>>();loop{match table_lua_iter.next(){Some(Some((lua::AnyLuaValue::LuaString(k), v))) => {
fns.push(v);}None | Some(None) => break,
_ => {},}}
and the error message:
error: no method named `next` found for type `lua::LuaTableIterator<'_, lua::PushGuard<&mut lua::Lua<'_>>, lua::AnyLuaValue, lua::LuaFunction<_>>` in the current scope
--> src/config.rs:94:34
|
94 | match table_lua_iter.next() {
| ^^^^
|
= note: the method `next` exists but the following trait bounds were not satisfied: `lua::LuaFunction<_> : lua::LuaRead<&'i mut &'j mut lua::LuaTableIterator<lua::PushGuard<&mut lua::Lua<'_>>, lua::AnyLuaValue, lua::LuaFunction<_>>>`
I thought LuaFunction implemented LuaRead but it is not working.
The text was updated successfully, but these errors were encountered:
I am trying to iterate over a table with functions unsuccessfully. I am not very experienced in Rust so I do not understand the compiler error. Here is my code:
and the error message:
I thought LuaFunction implemented LuaRead but it is not working.
The text was updated successfully, but these errors were encountered: