Add inherent versions of MaybeUninit methods for slices#129259
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 12, 2025
Merged
Add inherent versions of MaybeUninit methods for slices#129259bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is my attempt to un-stall #63569 and #79995, by creating methods that mirror the existing
MaybeUninitAPI:Adding these APIs:
Since the
assume_initmethods are identical to those on non-slices, they feel pretty natural. The main issue with the write methods is naming, as discussed in #79995 among other places. My rationale:write_clone_of_sliceandwrite_copy_of_slicesincecloneandcopyare being used as objects here, whereas they're being used as actions inclone_from_sliceandcopy_from_slice.The final "weird" thing I've done in this PR is remove a link to
Vec<T>fromassume_init_drop(both copies, since they're effectively copied docs), since there's no good way to link toVecfor something that can occur both on the page forstd/primitive.slice.htmlandstd/vec/struct.Vec.html, since the code here lives in libcore and can't use intra-doc-linking to mentionVec. (see: #121436)The reason why this method shows up both on
Vec<T>and[T]is because the[T]docs are automatically inlined onVec<T>'s page, since it implementsDeref. It's unfortunate that rustdoc doesn't have a way of dealing with this at the moment, but it is what it is, and it's a reasonable compromise for now.