@@ -634,7 +634,18 @@ impl<T: Default> Default for Rc<T> {
634
634
}
635
635
636
636
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
637
+ #[ cfg( stage0) ]
637
638
impl < T : PartialEq > PartialEq for Rc < T > {
639
+ #[ inline( always) ]
640
+ fn eq ( & self , other : & Rc < T > ) -> bool { * * self == * * other }
641
+
642
+ #[ inline( always) ]
643
+ fn ne ( & self , other : & Rc < T > ) -> bool { * * self != * * other }
644
+ }
645
+
646
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
647
+ #[ cfg( not( stage0) ) ]
648
+ impl < T : ?Sized + PartialEq > PartialEq for Rc < T > {
638
649
/// Equality for two `Rc<T>`s.
639
650
///
640
651
/// Two `Rc<T>`s are equal if their inner value are equal.
@@ -669,10 +680,35 @@ impl<T: PartialEq> PartialEq for Rc<T> {
669
680
}
670
681
671
682
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
683
+ #[ cfg( stage0) ]
672
684
impl < T : Eq > Eq for Rc < T > { }
685
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
686
+ #[ cfg( not( stage0) ) ]
687
+ impl < T : ?Sized + Eq > Eq for Rc < T > { }
673
688
674
689
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
690
+ #[ cfg( stage0) ]
675
691
impl < T : PartialOrd > PartialOrd for Rc < T > {
692
+ #[ inline( always) ]
693
+ fn partial_cmp ( & self , other : & Rc < T > ) -> Option < Ordering > {
694
+ ( * * self ) . partial_cmp ( & * * other)
695
+ }
696
+
697
+ #[ inline( always) ]
698
+ fn lt ( & self , other : & Rc < T > ) -> bool { * * self < * * other }
699
+
700
+ #[ inline( always) ]
701
+ fn le ( & self , other : & Rc < T > ) -> bool { * * self <= * * other }
702
+
703
+ #[ inline( always) ]
704
+ fn gt ( & self , other : & Rc < T > ) -> bool { * * self > * * other }
705
+
706
+ #[ inline( always) ]
707
+ fn ge ( & self , other : & Rc < T > ) -> bool { * * self >= * * other }
708
+ }
709
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
710
+ #[ cfg( not( stage0) ) ]
711
+ impl < T : ?Sized + PartialOrd > PartialOrd for Rc < T > {
676
712
/// Partial comparison for two `Rc<T>`s.
677
713
///
678
714
/// The two are compared by calling `partial_cmp()` on their inner values.
@@ -757,7 +793,14 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
757
793
}
758
794
759
795
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
796
+ #[ cfg( stage0) ]
760
797
impl < T : Ord > Ord for Rc < T > {
798
+ #[ inline]
799
+ fn cmp ( & self , other : & Rc < T > ) -> Ordering { ( * * self ) . cmp ( & * * other) }
800
+ }
801
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
802
+ #[ cfg( not( stage0) ) ]
803
+ impl < T : ?Sized + Ord > Ord for Rc < T > {
761
804
/// Comparison for two `Rc<T>`s.
762
805
///
763
806
/// The two are compared by calling `cmp()` on their inner values.
@@ -1399,4 +1442,9 @@ mod tests {
1399
1442
assert_eq ! ( format!( "{:?}" , foo) , "75" ) ;
1400
1443
}
1401
1444
1445
+ #[ test]
1446
+ fn test_unsized ( ) {
1447
+ let foo: Rc < [ i32 ] > = Rc :: new ( [ 1 , 2 , 3 ] ) ;
1448
+ assert_eq ! ( foo, foo. clone( ) ) ;
1449
+ }
1402
1450
}
0 commit comments