-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Add Object::set_native_object_data
#3480
Conversation
Object::set_native_object
Object::set_native_object_data
b4867bb
to
732da70
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3480 +/- ##
==========================================
- Coverage 44.59% 44.58% -0.01%
==========================================
Files 487 487
Lines 50601 50605 +4
==========================================
Hits 22563 22563
- Misses 28038 28042 +4 ☔ View full report in Codecov by Sentry. |
I'm pretty sure this change conflicts with #3479. In general, we ensure objects cannot change type after creation; this is to ensure APIs such as let data = ();
let object = JsObject::from_proto_and_data(proto, ObjectData::native_object(data));
let wrapper: JsNativeObject<()> = JsNativeObject::from_object(object).unwrap() // cannot panic
wrapper.borrow_mut().set_native_object_data(42u8);
let unit = wrapper.as_mut() // PANIC! |
I'm aware of this 😔 Unfortunately I'm not too sure what the best approach is. For some context, we'd like this to permit passing a unsafe |
Must you specifically use Otherwise, do you have a link to your use case? I'll try to think on an API that solves it without having to change the type of an object. |
Yes. So for some more context, we have our own Integrating the creation of a |
Nice! In that case, we can close this and plan the integration of |
Related issue: #3314
This PR permits one to set the native object data of a
Object
usingObject::set_native_object_data
.