From 79a57e3fbbbfd90857c903e0ec9f81e60426cade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20R=C3=A5gstad?= Date: Wed, 13 Sep 2023 13:55:21 +0200 Subject: [PATCH] Refactor function --- src/file/parser.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/file/parser.rs b/src/file/parser.rs index af5da67..dea99ba 100644 --- a/src/file/parser.rs +++ b/src/file/parser.rs @@ -421,28 +421,24 @@ impl<'a> WebXFileParser<'a> { call } - fn parse_handler_calls(&mut self) -> Vec { - 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 { 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![] }