Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 2 additions & 38 deletions library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::cmp::Ordering;
use crate::hash::{Hash, Hasher};
use crate::marker::{Destruct, StructuralPartialEq};
use crate::marker::Destruct;
use crate::mem::MaybeDangling;
use crate::ops::{Deref, DerefMut, DerefPure};
use crate::ptr;
Expand Down Expand Up @@ -155,7 +153,7 @@ use crate::ptr;
/// [`MaybeUninit`]: crate::mem::MaybeUninit
#[stable(feature = "manually_drop", since = "1.20.0")]
#[lang = "manually_drop"]
#[derive(Copy, Clone, Debug, Default)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
#[rustc_pub_transparent]
pub struct ManuallyDrop<T: ?Sized> {
Expand Down Expand Up @@ -289,37 +287,3 @@ impl<T: ?Sized> const DerefMut for ManuallyDrop<T> {

#[unstable(feature = "deref_pure_trait", issue = "87121")]
unsafe impl<T: ?Sized> DerefPure for ManuallyDrop<T> {}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized + Eq> Eq for ManuallyDrop<T> {}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized + PartialEq> PartialEq for ManuallyDrop<T> {
fn eq(&self, other: &Self) -> bool {
self.value.as_ref().eq(other.value.as_ref())
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> StructuralPartialEq for ManuallyDrop<T> {}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized + Ord> Ord for ManuallyDrop<T> {
fn cmp(&self, other: &Self) -> Ordering {
self.value.as_ref().cmp(other.value.as_ref())
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized + PartialOrd> PartialOrd for ManuallyDrop<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.value.as_ref().partial_cmp(other.value.as_ref())
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized + Hash> Hash for ManuallyDrop<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.value.as_ref().hash(state);
}
}
5 changes: 1 addition & 4 deletions library/core/src/mem/maybe_dangling.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![unstable(feature = "maybe_dangling", issue = "118166")]

use crate::marker::StructuralPartialEq;
use crate::{mem, ptr};

/// Allows wrapped [references] and [boxes] to dangle.
Expand Down Expand Up @@ -69,7 +68,7 @@ use crate::{mem, ptr};
/// [`ManuallyDrop`]: crate::mem::ManuallyDrop
#[repr(transparent)]
#[rustc_pub_transparent]
#[derive(Debug, Copy, Clone, Default)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[lang = "maybe_dangling"]
pub struct MaybeDangling<P: ?Sized>(P);

Expand Down Expand Up @@ -110,5 +109,3 @@ impl<P: ?Sized> MaybeDangling<P> {
x
}
}

impl<T: ?Sized> StructuralPartialEq for MaybeDangling<T> {}
Loading