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
{{ message }}
Repository navigation
Question: Is MetaMethod::IPairs missing for lua54? #635
Lua 5.4 does not support __ipairs metamethods (it was removed since 5.3).
You can use __index instead:
structMyUserData(i32);implLuaUserDataforMyUserData{fnadd_methods<M:LuaUserDataMethods<Self>>(methods:&mutM){
methods.add_meta_method(LuaMetaMethod::Index, |_lua, this,k:i32| {if k < this.0{returnOk(Some(k * k));}Ok(None)});}}
lua.load(r#" my_ud = ... for i, x in ipairs(my_ud) do print(i, x) end"#,).call::<()>(MyUserData(5)).unwrap();
or simply provide your own iterator function.
If you want to remove ipairs support, then your __index should return a error for integer keys.
Activity
khvzak commentedon Aug 31, 2025
Lua 5.4 does not support
__ipairsmetamethods (it was removed since 5.3).You can use
__indexinstead:or simply provide your own iterator function.
If you want to remove
ipairssupport, then your__indexshould return a error for integer keys.