-
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
Additional traits for std::mem::ManuallyDrop #44310
Conversation
Although types that don't implement Drop can't be Copyable, this can still be useful when ManuallyDrop is used inside a generic type. This doesn't derive from Copy as that would require T: Copy + Clone, instead it provides an impl of Clone for T: Clone.
Add pass-through implementations for all of the derivable traits. These cannot be derived since ManuallyDrop is a union.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BurntSushi (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
ping @BurntSushi for review! |
This seems fine to me, and I know I've been personally swayed in the past to add non-sensible impls in the name of generics since it seems rather harmless, but I'd still appreciate another set of eyes on this one. cc @rust-lang/libs |
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.
Seems okay to me.
sgtm |
@bors r+ |
📌 Commit 94301c4 has been approved by |
Additional traits for std::mem::ManuallyDrop The first commit adds `Clone` and `Copy` trait implementations for `ManuallyDrop`. Although `Drop` and `Copy` cannot be used together, this may be useful for generics. The second commit adds implementations common traits. I do not think this is necessary, as they could be implemented in a wrapper type outside the standard library, but it would make `ManuallyDrop` more convenient to use.
☀️ Test successful - status-appveyor, status-travis |
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
The first commit adds
Clone
andCopy
trait implementations forManuallyDrop
. AlthoughDrop
andCopy
cannot be used together, this may be useful for generics.The second commit adds implementations common traits. I do not think this is necessary, as they could be implemented in a wrapper type outside the standard library, but it would make
ManuallyDrop
more convenient to use.