-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 as_uninit
-like methods to pointer types and unify documentation of as_ref
methods
#75392
Conversation
Is there any particular reason why you added this for slices, but not for general pointers? It seems just as useful for |
That would would result in |
Maybe we could also add |
We probably want a method that converts between those two as well, but I don't know a good way to add such a method. :/
That's what I meant -- something like |
Me neither, we probably want a method converting in both direction with a decent name...
I'd name them |
I'd make them all one PR and one feature. |
Currently we have This btw. also applies to |
I can do technical reviews but this is a question for @rust-lang/libs that I cannot help with, I am afraid. |
I'll first implement the methods as they were already implemented with the pointer types. Since some methods are already stable, I think that a unified schema is the most important thing. |
I just noticed, that |
as_uninit_slice
to slice pointer typesas_uninit
-like methods to pointer types
One thing to note: |
Ah good point, and we are unlikely to be able to relax that sized bound. |
Those intra-doc links drive me crazy :D |
In terms of text this is all fine (assuming it's the same text for correspond methods, which I did not check in detail everywhere). I just have some more typographic nits. |
Thank you! |
as_uninit
-like methods to pointer typesas_uninit
-like methods to pointer types and unify documentation of as_ref
methods
All right, I think this is ready. :) Could you squash the commits? |
… of `as_ref` methods Fix example in `NonNull::as_uninit_slice` Rename feature gate to "ptr_as_uninit" Make methods more consistent with already stable methods Make `pointer::as_uninit_slice` return an `Option` Fix placement for `// SAFETY` section Add `as_uninit_ref` and `as_uninit_mut` to pointers Fix doctest Update tracking issue Fix doc links Apply suggestions from review Make wording about counterparts consistent Fix doc links Improve documentation Fix doc-tests Fix doc links ... again Apply suggestions from review Apply suggestions from Review Apply suggestion from review to all affected files Add missing words in safety sections in `as_uninit_slice_mut` Fix safety-comment in `NonNull::as_uninit_slice_mut`
a3a49ff
to
93e074b
Compare
Done (in case GH does not send mails on force-pushes). |
(it doesn't, except sometimes when it does... their support told me it only sends them when the parent of the new HEAD was already in the branch, aka when you just amended the last commit.) Great, and thanks for enduring by never-ending stream of editorial comments. :) |
📌 Commit 93e074b has been approved by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think the effort was worth it :) |
Rollup of 8 pull requests Successful merges: - rust-lang#75389 (attempt to improve span_label docs) - rust-lang#75392 (Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods) - rust-lang#75464 (Move to intra doc links for ascii.rs and panic.rs) - rust-lang#75578 (Allowing raw ptr dereference in const fn) - rust-lang#75613 (Add explanation for `&mut self` method call when expecting `-> Self`) - rust-lang#75626 (Clean up E0754 explanation) - rust-lang#75629 (Use intra-doc links in `std::env`, `std::alloc` and `std::error`) - rust-lang#75634 (Mark x86_64-linux-kernel as *) Failed merges: r? @ghost
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: #75402
r? @RalfJung