rune
rune copied to clipboard
`rebind!` macro
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.