Skip to content

Commit

Permalink
extract a function
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopedraza committed Apr 15, 2024
1 parent cf77e4c commit dac839b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ fn match_list(patterns: &[ASTNode], vals: &[Object]) -> MatchResult {

fn match_and_map(pattern: &ASTNode, val: &Object) -> MatchResult {
match pattern {
ASTNode::Symbol(s) => MatchResult::Match(vec![(s.to_string(), val.clone())]),
ASTNode::Symbol(s) => single_match(s, val),
ASTNode::Wildcard => empty_match(),
ASTNode::ExtensionList(l) => match_extension_list(l, val),
_ => match_constant(pattern, val),
}
}

fn single_match(name: &str, val: &Object) -> MatchResult {
MatchResult::Match(vec![(name.to_string(), val.clone())])
}

fn empty_match() -> MatchResult {
MatchResult::Match(vec![])
}
Expand Down

0 comments on commit dac839b

Please sign in to comment.