pub unsafe extern "C-unwind" fn lua_rawiter(
L: *mut lua_State,
idx: c_int,
iteration_index: c_int,
) -> c_intExpand description
Produces the next key and value pair from a table given the previous iteration index.
This function will iterate over the table at the given index, starting
from the array section, then iterating over the hashmap section. After
each call, the function returns an iteration index that should be passed
to the next call to continue iterating, and it will return -1 when
iteration is complete.
The function will push the key and value onto the stack.
A typical traversal of a table using this function would look like this:
// table is at index t
int iteration_index = 0; // start iteration with 0
while ((iteration_index = lua_rawiter(L, t, iteration_index)) != -1) {
// key is at index -2, value is at index -1
lua_pop(L, 2); // remove key and value
}