Skip to content

Commit d570bac

Browse files
committed
Nicer print_pats
As per @tamird's suggestion.
1 parent 0a01c49 commit d570bac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/libsyntax/print/pprust.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -2254,15 +2254,17 @@ impl<'a> State<'a> {
22542254
}
22552255

22562256
pub fn print_pats(&mut self, pats: &[P<ast::Pat>]) -> io::Result<()> {
2257-
let mut first = true;
2258-
for ref p in pats {
2259-
if first {
2260-
first = false;
2261-
} else {
2262-
try!(space(&mut self.s));
2263-
try!(self.word_space("|"));
2257+
match pats {
2258+
[] => {},
2259+
[ref p, ref ps..] => {
2260+
try!(self.print_pat(&*p));
2261+
2262+
for p in *ps {
2263+
try!(space(&mut self.s));
2264+
try!(self.word_space("|"));
2265+
try!(self.print_pat(&*p));
2266+
}
22642267
}
2265-
try!(self.print_pat(&**p));
22662268
}
22672269
Ok(())
22682270
}

0 commit comments

Comments
 (0)