From 8534fb4118c8059817af2d9cb348661c55e60233 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 4 Dec 2017 02:00:00 -0800 Subject: [PATCH] Tighten code --- src/rukka_lang/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index 7c06009..5cb88a2 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -128,13 +128,10 @@ fn tokenize(input: &mut Peekable) -> Vec { let string: String = input.scan(false, |escape, cur_char| { let seen_escape = *escape; *escape = cur_char == '\\' && !seen_escape; - - if cur_char == '"' && !seen_escape { - None - } else if cur_char == '\\' && !seen_escape { - Some(None) - } else { - Some(Some(cur_char)) + match (cur_char, seen_escape) { + ('"', false) => None, + ('\\', false) => Some(None), + (c, _) => Some(Some(c)) } }).filter_map(|x| x).collect(); tokens.push(StringLiteral(string));