pub unsafe extern "C-unwind" fn lua_next(
L: *mut lua_State,
idx: c_int,
) -> c_intExpand description
Produces the next key and value pair from a table given the previous key.
This function is equivalent to the Luau code next(t, k) where t is
the table at the given index, and k is the value at the top of the
stack. The key will be popped from the stack, and the resulting key and
value will be pushed onto the stack.
If the table has no more key-value pairs, this function will return 0
and will not push a key and value onto the stack, but the previous key
will still be popped from the stack.
A typical traversal of a table using this function would look like this:
// table is at index t
lua_pushnil(L); // push nil as the first key
while (lua_next(L, t) != 0) {
// key is at index -2, value is at index -1
lua_pop(L, 1); // remove value, keep key for next iteration
}This function, while still usable, is not recommended for use. Instead,
use lua_rawiter.