@@ -8,146 +8,6 @@ use crate::marker::{StructuralEq, StructuralPartialEq};
88//
99// Also provides implementations for tuples with lesser arity. For example, tuple_impls!(A B C)
1010// will implement everything for (A, B, C), (A, B) and (A,).
11- #[ cfg( bootstrap) ]
12- macro_rules! tuple_impls {
13- // Stopping criteria (1-ary tuple)
14- ( $T: ident) => {
15- tuple_impls!( @impl $T) ;
16- } ;
17- // Running criteria (n-ary tuple, with n >= 2)
18- ( $T: ident $( $U: ident ) +) => {
19- tuple_impls!( $( $U ) +) ;
20- tuple_impls!( @impl $T $( $U ) +) ;
21- } ;
22- // "Private" internal implementation
23- ( @impl $( $T: ident ) +) => {
24- maybe_tuple_doc! {
25- $( $T) + @
26- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
27- impl <$( $T: PartialEq ) ,+> PartialEq for ( $( $T, ) +)
28- where
29- last_type!( $( $T, ) +) : ?Sized
30- {
31- #[ inline]
32- fn eq( & self , other: & ( $( $T, ) +) ) -> bool {
33- $( ${ ignore( T ) } self . ${ index( ) } == other. ${ index( ) } ) &&+
34- }
35- #[ inline]
36- fn ne( & self , other: & ( $( $T, ) +) ) -> bool {
37- $( ${ ignore( T ) } self . ${ index( ) } != other. ${ index( ) } ) ||+
38- }
39- }
40- }
41-
42- maybe_tuple_doc! {
43- $( $T) + @
44- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
45- impl <$( $T: Eq ) ,+> Eq for ( $( $T, ) +)
46- where
47- last_type!( $( $T, ) +) : ?Sized
48- { }
49- }
50-
51- maybe_tuple_doc! {
52- $( $T) + @
53- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
54- impl <$( $T: ConstParamTy ) ,+> ConstParamTy for ( $( $T, ) +) { }
55- }
56-
57- maybe_tuple_doc! {
58- $( $T) + @
59- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
60- impl <$( $T) ,+> StructuralPartialEq for ( $( $T, ) +) { }
61- }
62-
63- maybe_tuple_doc! {
64- $( $T) + @
65- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
66- impl <$( $T) ,+> StructuralEq for ( $( $T, ) +) { }
67- }
68-
69- maybe_tuple_doc! {
70- $( $T) + @
71- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
72- impl <$( $T: PartialOrd ) ,+> PartialOrd for ( $( $T, ) +)
73- where
74- last_type!( $( $T, ) +) : ?Sized
75- {
76- #[ inline]
77- fn partial_cmp( & self , other: & ( $( $T, ) +) ) -> Option <Ordering > {
78- lexical_partial_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
79- }
80- #[ inline]
81- fn lt( & self , other: & ( $( $T, ) +) ) -> bool {
82- lexical_ord!( lt, Less , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
83- }
84- #[ inline]
85- fn le( & self , other: & ( $( $T, ) +) ) -> bool {
86- lexical_ord!( le, Less , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
87- }
88- #[ inline]
89- fn ge( & self , other: & ( $( $T, ) +) ) -> bool {
90- lexical_ord!( ge, Greater , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
91- }
92- #[ inline]
93- fn gt( & self , other: & ( $( $T, ) +) ) -> bool {
94- lexical_ord!( gt, Greater , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
95- }
96- }
97- }
98-
99- maybe_tuple_doc! {
100- $( $T) + @
101- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
102- impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +)
103- where
104- last_type!( $( $T, ) +) : ?Sized
105- {
106- #[ inline]
107- fn cmp( & self , other: & ( $( $T, ) +) ) -> Ordering {
108- lexical_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
109- }
110- }
111- }
112-
113- maybe_tuple_doc! {
114- $( $T) + @
115- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
116- impl <$( $T: Default ) ,+> Default for ( $( $T, ) +) {
117- #[ inline]
118- fn default ( ) -> ( $( $T, ) +) {
119- ( $( $T:: default ( ) , ) +)
120- }
121- }
122- }
123-
124- #[ stable( feature = "array_tuple_conv" , since = "1.71.0" ) ]
125- impl <T > From <[ T ; ${ count( T ) } ] > for ( $( ${ ignore( T ) } T , ) +) {
126- #[ inline]
127- #[ allow( non_snake_case) ]
128- fn from( array: [ T ; ${ count( T ) } ] ) -> Self {
129- let [ $( $T, ) +] = array;
130- ( $( $T, ) +)
131- }
132- }
133-
134- #[ stable( feature = "array_tuple_conv" , since = "1.71.0" ) ]
135- impl <T > From <( $( ${ ignore( T ) } T , ) +) > for [ T ; ${ count( T ) } ] {
136- #[ inline]
137- #[ allow( non_snake_case) ]
138- fn from( tuple: ( $( ${ ignore( T ) } T , ) +) ) -> Self {
139- let ( $( $T, ) +) = tuple;
140- [ $( $T, ) +]
141- }
142- }
143- }
144- }
145-
146- // Recursive macro for implementing n-ary tuple functions and operations
147- //
148- // Also provides implementations for tuples with lesser arity. For example, tuple_impls!(A B C)
149- // will implement everything for (A, B, C), (A, B) and (A,).
150- #[ cfg( not( bootstrap) ) ]
15111macro_rules! tuple_impls {
15212 // Stopping criteria (1-ary tuple)
15313 ( $T: ident) => {
0 commit comments