rune icon indicating copy to clipboard operation
rune copied to clipboard

`rebind!` macro

Open CeleritasCelery opened this issue 2 years ago • 0 comments

The rebind macro has this definition:

https://github.com/CeleritasCelery/rune/blob/7136b74386a4586537ffa59c3be4849cb76354fe/src/arena/mod.rs#L96-L102

We are casting the object into a raw form that removes the lifetime. Then we call an unsafe function to create a new object from that raw pointer

Why this is safe

We are not actually changing the &mut reference to Arena. Instead we are releasing it then reborrowing it immutabley. We make sure to shadow the name so the old binding is no longer available.

CeleritasCelery avatar Apr 11 '22 15:04 CeleritasCelery