-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove const qualifier if required #102
Conversation
@VisenDev what do you think of these changes? |
I generally oppose using const cast unless completely necessary. However, from what I can tell it does seem to be legal behavior to mutate the result of If mutating the result of a pub fn toString(lua: *Lua, index: i32) ![:0]const u8 { Rather than const casting its result. |
What I read on this page https://www.lua.org/manual/5.4/manual.html#lua_tolstring (look for section 4.1.3), it is safe to mutate the result of I think I'd rather allow the caller to use |
@axdank do you have any thoughts? Based on the lua reference manual 4.1.3, this could be a possible footgun depending on how the returned string would be used. The safest way would be to duplicate a const string if the string needs to be stored longer than Lua would keep that pointer valid. I can imagine that someone could use Maybe this is a case for |
@natecraddock How about these changes? I removed the use of @castConst, so if any structure needs a mutable string field, a copy of it is created. |
Thank you for working on this! |
fix: