File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,14 @@ impl fmt::Display for Final {
115
115
f. write_str ( "1" ) ?;
116
116
}
117
117
( CompleteBound :: Sum ( ..) , 0 ) | ( CompleteBound :: Product ( ..) , 0 ) => {
118
- f. write_str ( "(" ) ?;
118
+ if data. index > 0 {
119
+ f. write_str ( "(" ) ?;
120
+ }
119
121
}
120
122
( CompleteBound :: Sum ( ..) , 2 ) | ( CompleteBound :: Product ( ..) , 2 ) => {
121
- f. write_str ( ")" ) ?;
123
+ if data. index > 0 {
124
+ f. write_str ( ")" ) ?;
125
+ }
122
126
}
123
127
( CompleteBound :: Sum ( ..) , _) => f. write_str ( " + " ) ?,
124
128
( CompleteBound :: Product ( ..) , _) => f. write_str ( " × " ) ?,
@@ -216,9 +220,9 @@ mod tests {
216
220
assert_eq ! ( ty1. to_string( ) , "2^1024" ) ;
217
221
218
222
let sum = Final :: sum ( Final :: two_two_n ( 5 ) , Final :: two_two_n ( 10 ) ) ;
219
- assert_eq ! ( sum. to_string( ) , "( 2^32 + 2^1024) " ) ;
223
+ assert_eq ! ( sum. to_string( ) , "2^32 + 2^1024" ) ;
220
224
221
225
let prod = Final :: product ( Final :: two_two_n ( 5 ) , Final :: two_two_n ( 10 ) ) ;
222
- assert_eq ! ( prod. to_string( ) , "( 2^32 × 2^1024) " ) ;
226
+ assert_eq ! ( prod. to_string( ) , "2^32 × 2^1024" ) ;
223
227
}
224
228
}
Original file line number Diff line number Diff line change @@ -332,8 +332,16 @@ impl fmt::Display for Bound {
332
332
match ( & * data. node , data. n_children_yielded ) {
333
333
( Bound :: Free ( ref s) , _) => f. write_str ( s) ?,
334
334
( Bound :: Complete ( ref comp) , _) => fmt:: Display :: fmt ( comp, f) ?,
335
- ( Bound :: Sum ( ..) , 0 ) | ( Bound :: Product ( ..) , 0 ) => f. write_str ( "(" ) ?,
336
- ( Bound :: Sum ( ..) , 2 ) | ( Bound :: Product ( ..) , 2 ) => f. write_str ( ")" ) ?,
335
+ ( Bound :: Sum ( ..) , 0 ) | ( Bound :: Product ( ..) , 0 ) => {
336
+ if data. index > 0 {
337
+ f. write_str ( "(" ) ?
338
+ }
339
+ }
340
+ ( Bound :: Sum ( ..) , 2 ) | ( Bound :: Product ( ..) , 2 ) => {
341
+ if data. index > 0 {
342
+ f. write_str ( ")" ) ?
343
+ }
344
+ }
337
345
( Bound :: Sum ( ..) , _) => f. write_str ( " + " ) ?,
338
346
( Bound :: Product ( ..) , _) => f. write_str ( " × " ) ?,
339
347
}
You can’t perform that action at this time.
0 commit comments