2
2
3
3
use std:: fmt;
4
4
5
- #[ cfg( feature= "bigint" ) ]
5
+ #[ cfg( feature = "bigint" ) ]
6
6
use num_bigint:: BigUint ;
7
7
8
- #[ cfg( feature= "wtf8" ) ]
8
+ #[ cfg( feature = "wtf8" ) ]
9
9
use wtf8;
10
10
11
- #[ cfg( feature= "bigint" ) ]
11
+ #[ cfg( feature = "bigint" ) ]
12
12
pub type IntegerType = BigUint ;
13
- #[ cfg( not( feature= "bigint" ) ) ]
13
+ #[ cfg( not( feature = "bigint" ) ) ]
14
14
pub type IntegerType = u64 ;
15
15
16
- #[ cfg( feature= "wtf8" ) ]
16
+ #[ cfg( feature = "wtf8" ) ]
17
17
pub type PyStringContent = wtf8:: Wtf8Buf ;
18
- #[ cfg( feature= "wtf8" ) ]
18
+ #[ cfg( feature = "wtf8" ) ]
19
19
pub type PyStringCodePoint = wtf8:: CodePoint ;
20
20
21
- #[ cfg( not( feature= "wtf8" ) ) ]
21
+ #[ cfg( not( feature = "wtf8" ) ) ]
22
22
pub type PyStringContent = String ;
23
- #[ cfg( not( feature= "wtf8" ) ) ]
23
+ #[ cfg( not( feature = "wtf8" ) ) ]
24
24
pub type PyStringCodePoint = char ;
25
25
26
26
pub type Name = String ;
@@ -43,7 +43,7 @@ impl<T> Default for StarParams<T> {
43
43
}
44
44
45
45
/// The list of parameters of a function definition.
46
- #[ derive( Clone , Debug , PartialEq , Default , ) ]
46
+ #[ derive( Clone , Debug , PartialEq , Default ) ]
47
47
pub struct TypedArgsList {
48
48
pub positional_args : Vec < ( Name , Option < Expression > , Option < Expression > ) > ,
49
49
pub star_args : StarParams < ( Name , Option < Expression > ) > ,
@@ -99,12 +99,16 @@ pub enum Uop {
99
99
100
100
impl fmt:: Display for Uop {
101
101
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
102
- write ! ( f, "{}" , match * self {
103
- Uop :: Plus => "+" ,
104
- Uop :: Minus => "-" ,
105
- Uop :: Invert => "~" ,
106
- Uop :: Not => "not " ,
107
- } )
102
+ write ! (
103
+ f,
104
+ "{}" ,
105
+ match * self {
106
+ Uop :: Plus => "+" ,
107
+ Uop :: Minus => "-" ,
108
+ Uop :: Invert => "~" ,
109
+ Uop :: Not => "not " ,
110
+ }
111
+ )
108
112
}
109
113
}
110
114
@@ -144,42 +148,52 @@ pub enum Bop {
144
148
145
149
impl fmt:: Display for Bop {
146
150
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
147
- write ! ( f, "{}" , match * self {
148
- Bop :: Add => "+" ,
149
- Bop :: Sub => "-" ,
150
- Bop :: Mult => "*" ,
151
- Bop :: Matmult => "@" ,
152
- Bop :: Mod => "%" ,
153
- Bop :: Floordiv => "//" ,
154
- Bop :: Div => "/" ,
155
- Bop :: Power => "**" ,
156
- Bop :: Lshift => "<<" ,
157
- Bop :: Rshift => ">>" ,
158
- Bop :: BitAnd => "&" ,
159
- Bop :: BitXor => "^" ,
160
- Bop :: BitOr => "|" ,
161
- Bop :: Lt => "<" ,
162
- Bop :: Gt => ">" ,
163
- Bop :: Eq => "==" ,
164
- Bop :: Leq => "<=" ,
165
- Bop :: Geq => ">=" ,
166
- Bop :: Neq => "!=" ,
167
- Bop :: In => " in " ,
168
- Bop :: NotIn => " not in " ,
169
- Bop :: Is => " is " ,
170
- Bop :: IsNot => " is not " ,
171
- Bop :: And => " and " ,
172
- Bop :: Or => " or " ,
173
- } )
151
+ write ! (
152
+ f,
153
+ "{}" ,
154
+ match * self {
155
+ Bop :: Add => "+" ,
156
+ Bop :: Sub => "-" ,
157
+ Bop :: Mult => "*" ,
158
+ Bop :: Matmult => "@" ,
159
+ Bop :: Mod => "%" ,
160
+ Bop :: Floordiv => "//" ,
161
+ Bop :: Div => "/" ,
162
+ Bop :: Power => "**" ,
163
+ Bop :: Lshift => "<<" ,
164
+ Bop :: Rshift => ">>" ,
165
+ Bop :: BitAnd => "&" ,
166
+ Bop :: BitXor => "^" ,
167
+ Bop :: BitOr => "|" ,
168
+ Bop :: Lt => "<" ,
169
+ Bop :: Gt => ">" ,
170
+ Bop :: Eq => "==" ,
171
+ Bop :: Leq => "<=" ,
172
+ Bop :: Geq => ">=" ,
173
+ Bop :: Neq => "!=" ,
174
+ Bop :: In => " in " ,
175
+ Bop :: NotIn => " not in " ,
176
+ Bop :: Is => " is " ,
177
+ Bop :: IsNot => " is not " ,
178
+ Bop :: And => " and " ,
179
+ Bop :: Or => " or " ,
180
+ }
181
+ )
174
182
}
175
183
}
176
184
177
185
/// One of the `if` or `for` clause(s) of a comprehension list/dict/set or
178
186
/// generator expression.
179
187
#[ derive( Clone , Debug , PartialEq ) ]
180
188
pub enum ComprehensionChunk {
181
- If { cond : Expression } ,
182
- For { async : bool , item : Vec < Expression > , iterator : Expression } ,
189
+ If {
190
+ cond : Expression ,
191
+ } ,
192
+ For {
193
+ async : bool ,
194
+ item : Vec < Expression > ,
195
+ iterator : Expression ,
196
+ } ,
183
197
}
184
198
185
199
/// `**foo` or `foo:bar`, as in a dict comprehension.
@@ -259,7 +273,7 @@ pub enum Import {
259
273
path : Vec < Name > ,
260
274
/// For `from x import y, z`, this `vec![(y, None), (vec![z], None)]`.
261
275
/// For `from x import y as z`, this `vec![(y, Some(z))]`.
262
- names : Vec < ( Name , Option < Name > ) >
276
+ names : Vec < ( Name , Option < Name > ) > ,
263
277
} ,
264
278
/// For `from x import *`, this is `vec![]`.
265
279
ImportStarFrom {
@@ -268,7 +282,9 @@ pub enum Import {
268
282
} ,
269
283
/// `import x.y as z, foo.bar` is
270
284
/// `Import::Import(vec![(vec![x, y], Some(z)), (vec![foo, bar], None)])`.
271
- Import { names : Vec < ( Vec < Name > , Option < Name > ) > } ,
285
+ Import {
286
+ names : Vec < ( Vec < Name > , Option < Name > ) > ,
287
+ } ,
272
288
}
273
289
274
290
/// `+=` and its friends.
@@ -291,21 +307,25 @@ pub enum AugAssignOp {
291
307
292
308
impl fmt:: Display for AugAssignOp {
293
309
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
294
- write ! ( f, "{}" , match * self {
295
- AugAssignOp :: Add => "+=" ,
296
- AugAssignOp :: Sub => "-=" ,
297
- AugAssignOp :: Mult => "*=" ,
298
- AugAssignOp :: MatMult => "@=" ,
299
- AugAssignOp :: Div => "/=" ,
300
- AugAssignOp :: Mod => "%=" ,
301
- AugAssignOp :: BitAnd => "&=" ,
302
- AugAssignOp :: BitOr => "|=" ,
303
- AugAssignOp :: BitXor => "^=" ,
304
- AugAssignOp :: Lshift => "<<=" ,
305
- AugAssignOp :: Rshift => ">>=" ,
306
- AugAssignOp :: Power => "**=" ,
307
- AugAssignOp :: Floordiv => "//=" ,
308
- } )
310
+ write ! (
311
+ f,
312
+ "{}" ,
313
+ match * self {
314
+ AugAssignOp :: Add => "+=" ,
315
+ AugAssignOp :: Sub => "-=" ,
316
+ AugAssignOp :: Mult => "*=" ,
317
+ AugAssignOp :: MatMult => "@=" ,
318
+ AugAssignOp :: Div => "/=" ,
319
+ AugAssignOp :: Mod => "%=" ,
320
+ AugAssignOp :: BitAnd => "&=" ,
321
+ AugAssignOp :: BitOr => "|=" ,
322
+ AugAssignOp :: BitXor => "^=" ,
323
+ AugAssignOp :: Lshift => "<<=" ,
324
+ AugAssignOp :: Rshift => ">>=" ,
325
+ AugAssignOp :: Power => "**=" ,
326
+ AugAssignOp :: Floordiv => "//=" ,
327
+ }
328
+ )
309
329
}
310
330
}
311
331
@@ -375,7 +395,13 @@ pub struct Try {
375
395
#[ derive( Clone , Debug , PartialEq ) ]
376
396
pub enum CompoundStatement {
377
397
If ( Vec < ( Expression , Vec < Statement > ) > , Option < Vec < Statement > > ) ,
378
- For { async : bool , item : Vec < Expression > , iterator : Vec < Expression > , for_block : Vec < Statement > , else_block : Option < Vec < Statement > > } ,
398
+ For {
399
+ async : bool ,
400
+ item : Vec < Expression > ,
401
+ iterator : Vec < Expression > ,
402
+ for_block : Vec < Statement > ,
403
+ else_block : Option < Vec < Statement > > ,
404
+ } ,
379
405
While ( Expression , Vec < Statement > , Option < Vec < Statement > > ) ,
380
406
With ( Vec < ( Expression , Option < Expression > ) > , Vec < Statement > ) ,
381
407
Funcdef ( Funcdef ) ,
0 commit comments