@@ -22,6 +22,7 @@ use hash;
22
22
use intrinsics;
23
23
use marker:: { Copy , PhantomData , Sized } ;
24
24
use ptr;
25
+ use ops:: { Deref , DerefMut } ;
25
26
26
27
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
27
28
pub use intrinsics:: transmute;
@@ -871,7 +872,7 @@ impl<T> ManuallyDrop<T> {
871
872
}
872
873
873
874
#[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
874
- impl < T > :: ops :: Deref for ManuallyDrop < T > {
875
+ impl < T > Deref for ManuallyDrop < T > {
875
876
type Target = T ;
876
877
#[ inline]
877
878
fn deref ( & self ) -> & Self :: Target {
@@ -882,7 +883,7 @@ impl<T> ::ops::Deref for ManuallyDrop<T> {
882
883
}
883
884
884
885
#[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
885
- impl < T > :: ops :: DerefMut for ManuallyDrop < T > {
886
+ impl < T > DerefMut for ManuallyDrop < T > {
886
887
#[ inline]
887
888
fn deref_mut ( & mut self ) -> & mut Self :: Target {
888
889
unsafe {
@@ -903,16 +904,72 @@ impl<T: ::fmt::Debug> ::fmt::Debug for ManuallyDrop<T> {
903
904
#[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
904
905
impl < T : Clone > Clone for ManuallyDrop < T > {
905
906
fn clone ( & self ) -> Self {
906
- use :: ops:: Deref ;
907
907
ManuallyDrop :: new ( self . deref ( ) . clone ( ) )
908
908
}
909
909
910
910
fn clone_from ( & mut self , source : & Self ) {
911
- use :: ops:: DerefMut ;
912
911
self . deref_mut ( ) . clone_from ( source) ;
913
912
}
914
913
}
915
914
915
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
916
+ impl < T : Default > Default for ManuallyDrop < T > {
917
+ fn default ( ) -> Self {
918
+ ManuallyDrop :: new ( Default :: default ( ) )
919
+ }
920
+ }
921
+
922
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
923
+ impl < T : PartialEq > PartialEq for ManuallyDrop < T > {
924
+ fn eq ( & self , other : & Self ) -> bool {
925
+ self . deref ( ) . eq ( other)
926
+ }
927
+
928
+ fn ne ( & self , other : & Self ) -> bool {
929
+ self . deref ( ) . ne ( other)
930
+ }
931
+ }
932
+
933
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
934
+ impl < T : Eq > Eq for ManuallyDrop < T > { }
935
+
936
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
937
+ impl < T : PartialOrd > PartialOrd for ManuallyDrop < T > {
938
+ fn partial_cmp ( & self , other : & Self ) -> Option < :: cmp:: Ordering > {
939
+ self . deref ( ) . partial_cmp ( other)
940
+ }
941
+
942
+ fn lt ( & self , other : & Self ) -> bool {
943
+ self . deref ( ) . lt ( other)
944
+ }
945
+
946
+ fn le ( & self , other : & Self ) -> bool {
947
+ self . deref ( ) . le ( other)
948
+ }
949
+
950
+ fn gt ( & self , other : & Self ) -> bool {
951
+ self . deref ( ) . gt ( other)
952
+ }
953
+
954
+ fn ge ( & self , other : & Self ) -> bool {
955
+ self . deref ( ) . ge ( other)
956
+ }
957
+ }
958
+
959
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
960
+ impl < T : Ord > Ord for ManuallyDrop < T > {
961
+ fn cmp ( & self , other : & Self ) -> :: cmp:: Ordering {
962
+ self . deref ( ) . cmp ( other)
963
+ }
964
+ }
965
+
966
+ #[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
967
+ impl < T : :: hash:: Hash > :: hash:: Hash for ManuallyDrop < T > {
968
+ fn hash < H : :: hash:: Hasher > ( & self , state : & mut H ) {
969
+ self . deref ( ) . hash ( state) ;
970
+ }
971
+ }
972
+
916
973
/// Tells LLVM that this point in the code is not reachable, enabling further
917
974
/// optimizations.
918
975
///
0 commit comments