@@ -3767,6 +3767,179 @@ impl<T: ?Sized, A: Allocator> AsMut<T> for UniqueRc<T, A> {
3767
3767
#[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3768
3768
impl < T : ?Sized , A : Allocator > Unpin for UniqueRc < T , A > { }
3769
3769
3770
+ #[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3771
+ impl < T : ?Sized + PartialEq , A : Allocator > PartialEq for UniqueRc < T , A > {
3772
+ /// Equality for two `UniqueRc`s.
3773
+ ///
3774
+ /// Two `UniqueRc`s are equal if their inner values are equal.
3775
+ ///
3776
+ /// # Examples
3777
+ ///
3778
+ /// ```
3779
+ /// #![feature(unique_rc_arc)]
3780
+ /// use std::rc::UniqueRc;
3781
+ ///
3782
+ /// let five = UniqueRc::new(5);
3783
+ ///
3784
+ /// assert!(five == UniqueRc::new(5));
3785
+ /// ```
3786
+ #[ inline]
3787
+ fn eq ( & self , other : & Self ) -> bool {
3788
+ PartialEq :: eq ( & * * self , & * * other)
3789
+ }
3790
+
3791
+ /// Inequality for two `UniqueRc`s.
3792
+ ///
3793
+ /// Two `UniqueRc`s are not equal if their inner values are not equal.
3794
+ ///
3795
+ /// # Examples
3796
+ ///
3797
+ /// ```
3798
+ /// #![feature(unique_rc_arc)]
3799
+ /// use std::rc::UniqueRc;
3800
+ ///
3801
+ /// let five = UniqueRc::new(5);
3802
+ ///
3803
+ /// assert!(five != UniqueRc::new(6));
3804
+ /// ```
3805
+ #[ inline]
3806
+ fn ne ( & self , other : & Self ) -> bool {
3807
+ PartialEq :: ne ( & * * self , & * * other)
3808
+ }
3809
+ }
3810
+
3811
+ #[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3812
+ impl < T : ?Sized + PartialOrd , A : Allocator > PartialOrd for UniqueRc < T , A > {
3813
+ /// Partial comparison for two `UniqueRc`s.
3814
+ ///
3815
+ /// The two are compared by calling `partial_cmp()` on their inner values.
3816
+ ///
3817
+ /// # Examples
3818
+ ///
3819
+ /// ```
3820
+ /// #![feature(unique_rc_arc)]
3821
+ /// use std::rc::UniqueRc;
3822
+ /// use std::cmp::Ordering;
3823
+ ///
3824
+ /// let five = UniqueRc::new(5);
3825
+ ///
3826
+ /// assert_eq!(Some(Ordering::Less), five.partial_cmp(&UniqueRc::new(6)));
3827
+ /// ```
3828
+ #[ inline( always) ]
3829
+ fn partial_cmp ( & self , other : & UniqueRc < T , A > ) -> Option < Ordering > {
3830
+ ( * * self ) . partial_cmp ( & * * other)
3831
+ }
3832
+
3833
+ /// Less-than comparison for two `UniqueRc`s.
3834
+ ///
3835
+ /// The two are compared by calling `<` on their inner values.
3836
+ ///
3837
+ /// # Examples
3838
+ ///
3839
+ /// ```
3840
+ /// #![feature(unique_rc_arc)]
3841
+ /// use std::rc::UniqueRc;
3842
+ ///
3843
+ /// let five = UniqueRc::new(5);
3844
+ ///
3845
+ /// assert!(five < UniqueRc::new(6));
3846
+ /// ```
3847
+ #[ inline( always) ]
3848
+ fn lt ( & self , other : & UniqueRc < T , A > ) -> bool {
3849
+ * * self < * * other
3850
+ }
3851
+
3852
+ /// 'Less than or equal to' comparison for two `UniqueRc`s.
3853
+ ///
3854
+ /// The two are compared by calling `<=` on their inner values.
3855
+ ///
3856
+ /// # Examples
3857
+ ///
3858
+ /// ```
3859
+ /// #![feature(unique_rc_arc)]
3860
+ /// use std::rc::UniqueRc;
3861
+ ///
3862
+ /// let five = UniqueRc::new(5);
3863
+ ///
3864
+ /// assert!(five <= UniqueRc::new(5));
3865
+ /// ```
3866
+ #[ inline( always) ]
3867
+ fn le ( & self , other : & UniqueRc < T , A > ) -> bool {
3868
+ * * self <= * * other
3869
+ }
3870
+
3871
+ /// Greater-than comparison for two `UniqueRc`s.
3872
+ ///
3873
+ /// The two are compared by calling `>` on their inner values.
3874
+ ///
3875
+ /// # Examples
3876
+ ///
3877
+ /// ```
3878
+ /// #![feature(unique_rc_arc)]
3879
+ /// use std::rc::UniqueRc;
3880
+ ///
3881
+ /// let five = UniqueRc::new(5);
3882
+ ///
3883
+ /// assert!(five > UniqueRc::new(4));
3884
+ /// ```
3885
+ #[ inline( always) ]
3886
+ fn gt ( & self , other : & UniqueRc < T , A > ) -> bool {
3887
+ * * self > * * other
3888
+ }
3889
+
3890
+ /// 'Greater than or equal to' comparison for two `UniqueRc`s.
3891
+ ///
3892
+ /// The two are compared by calling `>=` on their inner values.
3893
+ ///
3894
+ /// # Examples
3895
+ ///
3896
+ /// ```
3897
+ /// #![feature(unique_rc_arc)]
3898
+ /// use std::rc::UniqueRc;
3899
+ ///
3900
+ /// let five = UniqueRc::new(5);
3901
+ ///
3902
+ /// assert!(five >= UniqueRc::new(5));
3903
+ /// ```
3904
+ #[ inline( always) ]
3905
+ fn ge ( & self , other : & UniqueRc < T , A > ) -> bool {
3906
+ * * self >= * * other
3907
+ }
3908
+ }
3909
+
3910
+ #[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3911
+ impl < T : ?Sized + Ord , A : Allocator > Ord for UniqueRc < T , A > {
3912
+ /// Comparison for two `UniqueRc`s.
3913
+ ///
3914
+ /// The two are compared by calling `cmp()` on their inner values.
3915
+ ///
3916
+ /// # Examples
3917
+ ///
3918
+ /// ```
3919
+ /// #![feature(unique_rc_arc)]
3920
+ /// use std::rc::UniqueRc;
3921
+ /// use std::cmp::Ordering;
3922
+ ///
3923
+ /// let five = UniqueRc::new(5);
3924
+ ///
3925
+ /// assert_eq!(Ordering::Less, five.cmp(&UniqueRc::new(6)));
3926
+ /// ```
3927
+ #[ inline]
3928
+ fn cmp ( & self , other : & UniqueRc < T , A > ) -> Ordering {
3929
+ ( * * self ) . cmp ( & * * other)
3930
+ }
3931
+ }
3932
+
3933
+ #[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3934
+ impl < T : ?Sized + Eq , A : Allocator > Eq for UniqueRc < T , A > { }
3935
+
3936
+ #[ unstable( feature = "unique_rc_arc" , issue = "112566" ) ]
3937
+ impl < T : ?Sized + Hash , A : Allocator > Hash for UniqueRc < T , A > {
3938
+ fn hash < H : Hasher > ( & self , state : & mut H ) {
3939
+ ( * * self ) . hash ( state) ;
3940
+ }
3941
+ }
3942
+
3770
3943
// Depends on A = Global
3771
3944
impl < T > UniqueRc < T > {
3772
3945
/// Creates a new `UniqueRc`.
0 commit comments