Handle tuples of length 1

This commit is contained in:
Gaëtan Cassiers 2015-05-30 16:52:46 +02:00
parent 38f421b764
commit 7a6b4db819
2 changed files with 5 additions and 0 deletions

View File

@ -198,6 +198,10 @@ impl<'a> FmtVisitor<'a> {
-> String {
// opening paren
let indent = offset + 1;
// In case of length 1, need a trailing comma
if items.len() == 1 {
return format!("({},)", self.rewrite_expr(&*items[0], width - 3, indent));
}
// Only last line has width-1 as budget, other may take max_width
let item_strs: Vec<_> =
items.iter()

View File

@ -7,4 +7,5 @@ fn foo() {
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaa);
let a = (a,);
}