cl-parser: Dedicated parsing logic for patterns!
This commit is contained in:
@@ -468,6 +468,7 @@ impl Display for Pattern {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Pattern::Name(sym) => sym.fmt(f),
|
||||
Pattern::Path(path) => path.fmt(f),
|
||||
Pattern::Literal(literal) => literal.fmt(f),
|
||||
Pattern::Rest(Some(name)) => write!(f, "..{name}"),
|
||||
Pattern::Rest(None) => "..".fmt(f),
|
||||
|
||||
@@ -338,6 +338,7 @@ impl WeightOf for Pattern {
|
||||
fn weight_of(&self) -> usize {
|
||||
match self {
|
||||
Pattern::Name(s) => size_of_val(s),
|
||||
Pattern::Path(p) => p.weight_of(),
|
||||
Pattern::Literal(literal) => literal.weight_of(),
|
||||
Pattern::Rest(Some(pattern)) => pattern.weight_of(),
|
||||
Pattern::Rest(None) => 0,
|
||||
|
||||
Reference in New Issue
Block a user