Skip to content
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

feat: unbox_snapshot to unbox Box<T> into @T #4425

Closed
1 of 2 tasks
enitrat opened this issue Nov 20, 2023 · 3 comments · Fixed by #4430
Closed
1 of 2 tasks

feat: unbox_snapshot to unbox Box<T> into @T #4425

enitrat opened this issue Nov 20, 2023 · 3 comments · Fixed by #4430
Labels
enhancement New feature or request

Comments

@enitrat
Copy link
Contributor

enitrat commented Nov 20, 2023

Feature Request

Describe the Feature Request

A libfunc/corelib function to unbox a Box<T> type into a @T type. This would allow us to not take ownership of the value inside the box when unboxing it, and would avoid unnecessary unbox-rebox operations when accessing a field of the T type without modifying it.

Describe Preferred Solution

A libfunc similar to match_nullable_snapshot - that converts a Box<T> to a @T.

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

I can try myself at it with some guidance

  • Yes
  • No
@enitrat enitrat added the enhancement New feature or request label Nov 20, 2023
@orizi
Copy link
Collaborator

orizi commented Nov 20, 2023

I think instead adding a: extern fn box_forward_snapshot<T>(value: @Box<T>) -> Box<@T>; would be better (less actual logic).
same for: extern fn nullable_forward_snapshot<T>(value: @Nullable<T>) -> Nullable<@T>; - this can probably replace match_nullable_snapshot as well.
I'm wondering if having the opposite as well would be beneficial.

@enitrat
Copy link
Contributor Author

enitrat commented Nov 20, 2023

I think instead adding a: extern fn box_forward_snapshot(value: @box) -> Box<@t>; would be better (less actual logic).

Sounds good!

I'm wondering if having the opposite as well would be beneficial.

I don't see any specific use case for this. Do you mean @T into Box<T>?

@orizi
Copy link
Collaborator

orizi commented Nov 20, 2023

no - just instead of forwarding the snapshot pulling it backwards - i indeed don't see a particular usecase.

@orizi orizi linked a pull request Nov 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants