-
Notifications
You must be signed in to change notification settings - Fork 9
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
Return MaybeUninit<u8>
rather than u8
#66
Comments
If |
With rust-lang/rust#74850 it will be separate again. |
I don't particularly like this idea. The current plan is to return a |
I don't think things like copying via |
pub type Byte = MaybeUninit<u8>;
pub type Bytes = [Byte]; |
After playing a bit around with @RalfJung Is there a plan to add something like |
I don't know of any such plans, but these sound like useful methods. Basically they would be safe to call whenever the pointer is dereferencable and the aliasing guarantees are met, but there are no requirements of whether the pointee is initialized or not. |
…r=RalfJung Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods This adds a convenient method to retrieve a `&(mut) [MaybeUninit<T>]` from slice pointers (`*const [T]`, `*mut [T]`, `NonNull<[T]>`). See also rust-lang/wg-allocators#66 (comment). ~I'll add a tracking issue as soon as it's reviewed and CI passed.~ Tracking Issue: rust-lang#75402 r? @RalfJung
We should considor to return
MaybeUninit
at allocating methods. While it'sunsafe
to dereference pointers and the caller has to ensure the validity of the pointer anyway, it's an hint, that the memory may be uninitialized. I don't expect much effect to the end user, as in most cases, the returned pointer will be casted anyway.The text was updated successfully, but these errors were encountered: