simplify root parser
authoralfadur
Tue, 04 Jun 2019 23:44:01 +0300
changeset 15143 4f31954a0b81
parent 15142 1a43b570cbe4
child 15144 1aa3b44c0441
simplify root parser
rust/hedgewars-server/src/protocol/parser.rs
--- a/rust/hedgewars-server/src/protocol/parser.rs	Tue Jun 04 22:37:42 2019 +0200
+++ b/rust/hedgewars-server/src/protocol/parser.rs	Tue Jun 04 23:44:01 2019 +0300
@@ -13,7 +13,7 @@
     combinator::{map, peek},
     error::{ErrorKind, ParseError},
     multi::separated_list,
-    sequence::{pair, preceded, terminated},
+    sequence::{delimited, pair, preceded, terminated},
     Err, IResult,
 };
 
@@ -458,19 +458,17 @@
 }
 
 pub fn message(input: &[u8]) -> HwResult<HwProtocolMessage> {
-    preceded(
+    delimited(
         take_while(|c| c == b'\n'),
-        terminated(
-            alt((
-                no_arg_message,
-                single_arg_message,
-                cmd_message,
-                config_message,
-                server_var_message,
-                complex_message,
-            )),
-            end_of_message,
-        ),
+        alt((
+            no_arg_message,
+            single_arg_message,
+            cmd_message,
+            config_message,
+            server_var_message,
+            complex_message,
+        )),
+        end_of_message,
     )(input)
 }