Skip to content

Commit

Permalink
Refactor function
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRagstad committed Sep 13, 2023
1 parent 1d28ae7 commit 79a57e3
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/file/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,28 +421,24 @@ impl<'a> WebXFileParser<'a> {
call
}

fn parse_handler_calls(&mut self) -> Vec<String> {
let mut calls = vec![];
loop {
self.skip_whitespace(true);
calls.push(self.parse_handler_call());
self.skip_whitespace(true);
let nc = self.peek();
if nc.is_none() { break; }
let nc = nc.unwrap();
if nc != ',' { break; }
self.next();
}
calls
}

fn parse_route_handlers(&mut self) -> Vec<String> {
let context = "while parsing route handlers";
self.skip_whitespace(true);
match self.peek() {
Some('-') => {
self.expect_specific_str("->", 0, context);
self.parse_handler_calls()
let mut calls = vec![];
loop {
self.skip_whitespace(true);
calls.push(self.parse_handler_call());
self.skip_whitespace(true);
let nc = self.peek();
if nc.is_none() { break; }
let nc = nc.unwrap();
if nc != ',' { break; }
self.next();
}
calls
},
_ => vec![]
}
Expand Down

0 comments on commit 79a57e3

Please sign in to comment.