rust-lua53 icon indicating copy to clipboard operation
rust-lua53 copied to clipboard

`&mut self` not required for `is_*`, most `to_*`, `check_*`, and `opt_*` functions, and some others.

Open Parakleta opened this issue 9 years ago • 1 comments

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.

Parakleta avatar Jun 09 '16 06:06 Parakleta

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.

therustmonk avatar Jul 12 '16 10:07 therustmonk