-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Way to create a Rc<[T]> from a Vec<T> #1979
Comments
See #1138 |
I hope people are not using transmute, because you can't safely transmute one to the other without resizing the allocation to make room for the reference counts. |
We can already convert |
Although I'm curious, why would anyone use unsafe code, or even |
This comment would also be relevant: rust-lang/rust#29953 (comment)
|
You could create new |
I suspect the usual use case would be that the code would build the array in |
Does any code actually do this conversion at the moment? Even if allocator magic as proposed by @eddyb is accepted, it will take a lot of time to land, but experiments like |
This has been accepted in RFC 1845 -- https://github.com/rust-lang/rfcs/blob/master/text/1845-shared-from-slice.md, tracking issue rust-lang/rust#40475. |
It should be possible to create an
Rc<[T]>
from aVec<T>
, but that is not possible right now without heavy use oftransmute
(which I'm sure some people are doing).The text was updated successfully, but these errors were encountered: