Prefer to put the whole pattern of match arm on one line

This commit is contained in:
Seiichi Uchida 2017-07-10 02:18:53 +09:00
parent 72b155a9e2
commit b897310d79

View File

@ -1687,14 +1687,14 @@ impl Rewrite for ast::Arm {
.collect::<Option<Vec<_>>>()
);
let all_simple = pat_strs.iter().all(|p| pat_is_simple(p));
let all_simple = pat_strs.iter().all(|p| !p.contains('\n'));
let items: Vec<_> = pat_strs.into_iter().map(ListItem::from_str).collect();
let mut tactic = definitive_tactic(&items, ListTactic::HorizontalVertical, pat_shape.width);
if tactic == DefinitiveListTactic::Horizontal && all_simple {
tactic = DefinitiveListTactic::Mixed;
}
let fmt = ListFormatting {
tactic: if all_simple {
DefinitiveListTactic::Mixed
} else {
DefinitiveListTactic::Vertical
},
tactic: tactic,
separator: " |",
trailing_separator: SeparatorTactic::Never,
shape: pat_shape,