Skip to content
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

Missing mutable borrows for Table<'lua> #266

Closed
CXWorks opened this issue Apr 28, 2023 · 2 comments
Closed

Missing mutable borrows for Table<'lua> #266

CXWorks opened this issue Apr 28, 2023 · 2 comments

Comments

@CXWorks
Copy link

CXWorks commented Apr 28, 2023

Hi,

There may be a Rust violation on changing the value of immutable reference in Table<'lua>.

Its setter methods change the state of self as an immutbale reference.

Could you please help me check if this is a bug or design decision? Thx

https://github.com/amethyst/rlua/blob/262180ff21acf01cdb5c4cb5605feb985bf4d284/src/table.rs#L51-L69

https://github.com/amethyst/rlua/blob/262180ff21acf01cdb5c4cb5605feb985bf4d284/src/table.rs#L228-L241

@CXWorks
Copy link
Author

CXWorks commented Apr 28, 2023

Duplicated by #48

@CXWorks CXWorks closed this as completed Apr 28, 2023
@jugglerchris
Copy link
Collaborator

Good job finding the earlier issue!

In case it helps, it sometimes makes more sense thinking of & and &mut as shared/exclusive references, respectively rather than immutable/mutable. It just happens that with simple types it's safe to mutate things you have an exclusive reference to, but Lua types inherently can have multiple references to each other so an exclusive reference doesn't make much sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants