From 55432d2df2c3957b7bd022d163c9cec6b317376e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 Sep 2018 17:01:34 +0200 Subject: Extract action normal character parsing to a function Splits up the `action_map()` function and gives the parser a name. --- src/parser.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 05d7dd1..d82cdaf 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -207,19 +207,27 @@ where ( many( choice!( - satisfy(|c| c != '<') - .map(|c| - KeyboardKeyWithModifiers::new( - KeyboardKey::Character(Character::new(c)), - None, - ) - ), + action_character(), special_key() ) ), ).map(|(keys,)| Action::Map(keys)) } +fn action_character() -> impl Parser +where + I: Stream, + I::Error: ParseError, +{ + satisfy(|c| c != '<') + .map(|c| + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new(c)), + None, + ) + ) +} + fn special_key() -> impl Parser where I: Stream, -- cgit v1.2.3