mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
parent
5f74e10d32
commit
ca5d084497
17 changed files with 369 additions and 25 deletions
|
@ -43,7 +43,9 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
| Pattern::QualifiedIdentifier { .. }
|
||||
| Pattern::ListRest => false,
|
||||
|
||||
Pattern::List(patterns) => patterns.iter().any(|p| p.is_multiline()),
|
||||
Pattern::Tuple(patterns) | Pattern::List(patterns) => {
|
||||
patterns.iter().any(|p| p.is_multiline())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,6 +164,22 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
buf.push('_');
|
||||
buf.push_str(name);
|
||||
}
|
||||
Tuple(loc_patterns) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str("(");
|
||||
|
||||
let mut it = loc_patterns.iter().peekable();
|
||||
while let Some(loc_pattern) = it.next() {
|
||||
loc_pattern.format(buf, indent);
|
||||
|
||||
if it.peek().is_some() {
|
||||
buf.push_str(",");
|
||||
buf.spaces(1);
|
||||
}
|
||||
}
|
||||
|
||||
buf.push_str(")");
|
||||
}
|
||||
List(loc_patterns) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str("[");
|
||||
|
|
|
@ -753,6 +753,7 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
|
|||
Pattern::SpaceAfter(a, _) => a.remove_spaces(arena),
|
||||
Pattern::SingleQuote(a) => Pattern::SingleQuote(a),
|
||||
Pattern::List(pats) => Pattern::List(pats.remove_spaces(arena)),
|
||||
Pattern::Tuple(pats) => Pattern::Tuple(pats.remove_spaces(arena)),
|
||||
Pattern::ListRest => Pattern::ListRest,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue