Skip to content

Commit

Permalink
Replace if statements with match
Browse files Browse the repository at this point in the history
  • Loading branch information
39bytes committed Jul 22, 2023
1 parent 0461997 commit a392a7a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions crates/extractor/src/req_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,14 @@ fn postprocess(req: &ReqNode) -> Option<ReqNode> {
ReqNode::Group { groups, operator } => {
let flattened: Vec<_> = groups.iter().filter_map(postprocess).collect();

if flattened.is_empty() {
return None;
}
if flattened.len() == 1 {
return postprocess(&flattened[0]);
match flattened.len() {
0 => None,
1 => postprocess(&flattened[0]),
_ => Some(ReqNode::Group {
operator: operator.clone(),
groups: flattened,
}),
}

Some(ReqNode::Group {
operator: operator.clone(),
groups: flattened,
})
}
}
}
Expand Down

0 comments on commit a392a7a

Please sign in to comment.