Format list patterns

This commit is contained in:
Ayaz Hafiz 2022-10-26 17:08:10 -05:00
parent 4d35ab9957
commit 9bb523ce97
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 79 additions and 2 deletions

View file

@ -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) => {