conlang: Add Tuple-Struct Patterns
- Patterns are no longer parsed with the highest precedence - Function calls with just a path and a tuple of args can now be transformed into a Pattern
This commit is contained in:
@@ -267,6 +267,13 @@ pub trait Fold {
|
||||
.map(|(name, bind)| (name, bind.map(|p| self.fold_pattern(p))))
|
||||
.collect(),
|
||||
),
|
||||
Pattern::TupleStruct(path, items) => Pattern::TupleStruct(
|
||||
self.fold_path(path),
|
||||
items
|
||||
.into_iter()
|
||||
.map(|bind| self.fold_pattern(bind))
|
||||
.collect(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,10 @@ pub trait Visit<'a>: Sized {
|
||||
});
|
||||
});
|
||||
}
|
||||
Pattern::TupleStruct(path, items) => {
|
||||
self.visit_path(path);
|
||||
items.iter().for_each(|bind| self.visit_pattern(bind));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user