@@ -19,75 +19,103 @@ macro_rules! tuple_impls {
1919 } ;
2020 // "Private" internal implementation
2121 ( @impl $( $T: ident ) +) => {
22- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23- impl <$( $T: PartialEq ) ,+> PartialEq for ( $( $T, ) +)
24- where
25- last_type!( $( $T, ) +) : ?Sized
26- {
27- #[ inline]
28- fn eq( & self , other: & ( $( $T, ) +) ) -> bool {
29- $( ${ ignore( T ) } self . ${ index( ) } == other. ${ index( ) } ) &&+
30- }
31- #[ inline]
32- fn ne( & self , other: & ( $( $T, ) +) ) -> bool {
33- $( ${ ignore( T ) } self . ${ index( ) } != other. ${ index( ) } ) ||+
22+ maybe_tuple_doc! {
23+ $( $T) + @
24+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
25+ impl <$( $T: PartialEq ) ,+> PartialEq for ( $( $T, ) +)
26+ where
27+ last_type!( $( $T, ) +) : ?Sized
28+ {
29+ #[ inline]
30+ fn eq( & self , other: & ( $( $T, ) +) ) -> bool {
31+ $( ${ ignore( T ) } self . ${ index( ) } == other. ${ index( ) } ) &&+
32+ }
33+ #[ inline]
34+ fn ne( & self , other: & ( $( $T, ) +) ) -> bool {
35+ $( ${ ignore( T ) } self . ${ index( ) } != other. ${ index( ) } ) ||+
36+ }
3437 }
3538 }
3639
37- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
38- impl <$( $T: Eq ) ,+> Eq for ( $( $T, ) +)
39- where
40- last_type!( $( $T, ) +) : ?Sized
41- { }
40+ maybe_tuple_doc! {
41+ $( $T) + @
42+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
43+ impl <$( $T: Eq ) ,+> Eq for ( $( $T, ) +)
44+ where
45+ last_type!( $( $T, ) +) : ?Sized
46+ { }
47+ }
4248
43- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
44- impl <$( $T: PartialOrd + PartialEq ) ,+> PartialOrd for ( $( $T, ) +)
45- where
46- last_type!( $( $T, ) +) : ?Sized
47- {
48- #[ inline]
49- fn partial_cmp( & self , other: & ( $( $T, ) +) ) -> Option <Ordering > {
50- lexical_partial_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
51- }
52- #[ inline]
53- fn lt( & self , other: & ( $( $T, ) +) ) -> bool {
54- lexical_ord!( lt, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
55- }
56- #[ inline]
57- fn le( & self , other: & ( $( $T, ) +) ) -> bool {
58- lexical_ord!( le, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
59- }
60- #[ inline]
61- fn ge( & self , other: & ( $( $T, ) +) ) -> bool {
62- lexical_ord!( ge, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
63- }
64- #[ inline]
65- fn gt( & self , other: & ( $( $T, ) +) ) -> bool {
66- lexical_ord!( gt, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
49+ maybe_tuple_doc! {
50+ $( $T) + @
51+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
52+ impl <$( $T: PartialOrd + PartialEq ) ,+> PartialOrd for ( $( $T, ) +)
53+ where
54+ last_type!( $( $T, ) +) : ?Sized
55+ {
56+ #[ inline]
57+ fn partial_cmp( & self , other: & ( $( $T, ) +) ) -> Option <Ordering > {
58+ lexical_partial_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
59+ }
60+ #[ inline]
61+ fn lt( & self , other: & ( $( $T, ) +) ) -> bool {
62+ lexical_ord!( lt, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
63+ }
64+ #[ inline]
65+ fn le( & self , other: & ( $( $T, ) +) ) -> bool {
66+ lexical_ord!( le, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
67+ }
68+ #[ inline]
69+ fn ge( & self , other: & ( $( $T, ) +) ) -> bool {
70+ lexical_ord!( ge, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
71+ }
72+ #[ inline]
73+ fn gt( & self , other: & ( $( $T, ) +) ) -> bool {
74+ lexical_ord!( gt, $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
75+ }
6776 }
6877 }
6978
70- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
71- impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +)
72- where
73- last_type!( $( $T, ) +) : ?Sized
74- {
75- #[ inline]
76- fn cmp( & self , other: & ( $( $T, ) +) ) -> Ordering {
77- lexical_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
79+ maybe_tuple_doc! {
80+ $( $T) + @
81+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
82+ impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +)
83+ where
84+ last_type!( $( $T, ) +) : ?Sized
85+ {
86+ #[ inline]
87+ fn cmp( & self , other: & ( $( $T, ) +) ) -> Ordering {
88+ lexical_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
89+ }
7890 }
7991 }
8092
81- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
82- impl <$( $T: Default ) ,+> Default for ( $( $T, ) +) {
83- #[ inline]
84- fn default ( ) -> ( $( $T, ) +) {
85- ( $( { let x: $T = Default :: default ( ) ; x} , ) +)
93+ maybe_tuple_doc! {
94+ $( $T) + @
95+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
96+ impl <$( $T: Default ) ,+> Default for ( $( $T, ) +) {
97+ #[ inline]
98+ fn default ( ) -> ( $( $T, ) +) {
99+ ( $( { let x: $T = Default :: default ( ) ; x} , ) +)
100+ }
86101 }
87102 }
88103 }
89104}
90105
106+ macro_rules! maybe_tuple_doc {
107+ ( $a: ident @ #[ $meta: meta] $item: item) => {
108+ #[ doc = "This trait is implemented for tuples up to twelve items long." ]
109+ #[ $meta]
110+ $item
111+ } ;
112+ ( $a: ident $( $rest_a: ident) + @ #[ $meta: meta] $item: item) => {
113+ #[ doc( hidden) ]
114+ #[ $meta]
115+ $item
116+ } ;
117+ }
118+
91119// Constructs an expression that performs a lexical ordering using method $rel.
92120// The values are interleaved, so the macro invocation for
93121// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
0 commit comments