@@ -55,6 +55,19 @@ fn is_short_pattern_inner(pat: &ast::Pat) -> bool {
55
55
}
56
56
}
57
57
58
+ struct RangeOperand < ' a > ( & ' a Option < ptr:: P < ast:: Expr > > ) ;
59
+
60
+ impl < ' a > Rewrite for RangeOperand < ' a > {
61
+ fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
62
+ match & self . 0 {
63
+ None => Some ( "" . to_owned ( ) ) ,
64
+ Some ( ref exp) => {
65
+ exp. rewrite ( context, shape)
66
+ }
67
+ }
68
+ }
69
+ }
70
+
58
71
impl Rewrite for Pat {
59
72
fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
60
73
match self . kind {
@@ -180,16 +193,6 @@ impl Rewrite for Pat {
180
193
}
181
194
}
182
195
PatKind :: Range ( ref lhs, ref rhs, ref end_kind) => {
183
- impl Rewrite for Option < ptr:: P < ast:: Expr > > {
184
- fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
185
- match & self {
186
- None => Some ( "" . to_owned ( ) ) ,
187
- Some ( ref exp) => {
188
- exp. rewrite ( context, shape)
189
- }
190
- }
191
- }
192
- }
193
196
let infix = match end_kind. node {
194
197
RangeEnd :: Included ( RangeSyntax :: DotDotDot ) => "..." ,
195
198
RangeEnd :: Included ( RangeSyntax :: DotDotEq ) => "..=" ,
@@ -209,8 +212,8 @@ impl Rewrite for Pat {
209
212
infix. to_owned ( )
210
213
} ;
211
214
rewrite_pair (
212
- lhs,
213
- rhs,
215
+ & RangeOperand ( lhs) ,
216
+ & RangeOperand ( rhs) ,
214
217
PairParts :: infix ( & infix) ,
215
218
context,
216
219
shape,
0 commit comments