-
Notifications
You must be signed in to change notification settings - Fork 77
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
GenericArray
should implement Index{,Mut}
as well as a way to get a pointer to a field
#75
Comments
A partially-uninitialized However, there are intentionally undocumented but publicly exported structures in See here for Likewise, there is also The primary difference is their If you must use uninitialized memory with As for |
I'm pretty deep into unsafe stuff, and so long as Line 195 in 459abe4
Having And the “way to get a pointer to a field” from the title would allow for a way to initialize an element without insta-UB, as getting a reference to a not-yet-initialized item is officially UB. |
Dereferencing into a slice is totally fine so long as you don't read uninitialized data or overwrite initialized data. A slice doesn't own the memory, so it can't drop it. The entire reason Slices are a magical construct in Rust, and allow for incredible optimizations when used. In fact, Something you cannot do is random-access initialize/deinitialize elements, which is what it sounds like you want. If the types you want are |
It is not. The fact the slice won't drop the memory does not make it not-UB to have a slice pointing to undefined memory. rust-lang/rfcs#1892 (comment) explicitly reminds it. And rust-lang/rfcs#1892 (comment) is a nice example of why it's hard to do it any other way, for optimization purposes. Now, we totally agree that in practice it should work most of the time, but it is not guaranteed by current Rust.
Well, my types are not My main issue has been that for this I needed to do |
Hi, I'd like to revive this issue. |
This would make it possible to handle partially-
uninitialized
GenericArray
s without insta-UB.Thank you for your work on generic-array :)
The text was updated successfully, but these errors were encountered: