rust-lua53
rust-lua53 copied to clipboard
Use ptr::write in example
This example for function State::new_userdata_typed is only correct if MyStruct does not have a destructor. The correct way to move a value into an uninitialized location is std::ptr::write
The given example:
unsafe { *state.new_userdata_typed() = MyStruct::new(...); }
state.set_metatable_from_registry("MyStruct");