rust-lua53
rust-lua53 copied to clipboard
`&mut self` not required for `is_*`, most `to_*`, `check_*`, and `opt_*` functions, and some others.
The is_* functions do not modify state at all, and having that reflected in their signature makes matches easier.
All of the to_*, check_*, and opt_* functions do not modify state except for those involving strings (including check_option). It is probably still worth considering the pointer returning methods as mutable if they return mutable objects/pointers.
The abs_index, get_top, type_of, typename_of, raw_len, and typename_at also don't mutate the state.
There may be others I have missed.
This somewhat limits.
Internally all of is_ methods calls:
LUA_API int lua_type (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
return (isvalid(o) ? ttnov(o) : LUA_TNONE);
}
Which never mutate state. I can offer PR to fix it.