What should I do if I want to keep a reference in Rust side?
yfractal opened this issue · comments
Mike Yang commented
For example:
fn ruby_insert(key: RString, obj: AnyObject) -> AnyObject {
let struct = rtself.get_data_mut(&*STORE_WRAPPER);
let ruby_obj = RubyObject::from(obj.unwrap().value());
struct
.hash_map
.insert(key.unwrap().to_string(), Arc::new(ruby_obj));
NilClass::new().into()
},
I think I have to pin the object first to avoid the memory being moved and then keep a reference in rtself
to avoid the memory has been freed.
Are there any other things I need to do?