-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 inherent versions of MaybeUninit methods for slices #129259
base: master
Are you sure you want to change the base?
Conversation
a88bac8
to
b3cf03f
Compare
This comment has been minimized.
This comment has been minimized.
// guard is needed b/c panic might happen during a clone | ||
let mut guard = Guard { slice: self, initialized: 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test for panic during clone would probably be good to verify expected behavior
/// | ||
/// [`Vec<T>`]: ../../std/vec/struct.Vec.html | ||
#[unstable(feature = "maybe_uninit_slice", issue = "63569")] | ||
pub unsafe fn assume_init_drop(&mut self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assume_init_*
methods could probably use examples.
The implementation looks pretty reasonable to me, but as this is an API decision: r? libs-api Is the intent here to replace the existing |
I decided to not delete them since so many people are using these methods, but I can deprecate them depending on what people think is best. |
b3cf03f
to
ecb920d
Compare
This comment has been minimized.
This comment has been minimized.
ecb920d
to
45caae8
Compare
This comment has been minimized.
This comment has been minimized.
45caae8
to
0cd81e0
Compare
0cd81e0
to
6641ecd
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
We discussed this in the libs-api meeting. We're happy with these changes, but we would also like to see similar changes for the Also, the old methods on |
This is my attempt to un-stall #63569 and #79995, by creating methods that mirror the existing
MaybeUninit
API:Offering these new methods:
Since the
assume_init
methods 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_slice
andwrite_copy_of_slice
sinceclone
andcopy
are being used as nouns here, whereas they're being used as verbs inclone_from_slice
andcopy_from_slice
.I'm hoping these don't require an ACP since they're just refining upon existing APIs, but I can write one up if you prefer.