mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Format list patterns
This commit is contained in:
parent
4d35ab9957
commit
9bb523ce97
2 changed files with 79 additions and 2 deletions
|
@ -161,8 +161,26 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
buf.push('_');
|
||||
buf.push_str(name);
|
||||
}
|
||||
List(..) => todo!(),
|
||||
ListRest => todo!(),
|
||||
List(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("]");
|
||||
}
|
||||
ListRest => {
|
||||
buf.indent(indent);
|
||||
buf.push_str("..");
|
||||
}
|
||||
|
||||
// Space
|
||||
SpaceBefore(sub_pattern, spaces) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue