From d203f2689ac7addf36a32150691f459212199f09 Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 28 Oct 2017 23:34:30 +0200 Subject: Reformat the emoji counting loop --- src/plugins/emoji.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index 99f6c26..09d5c27 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -46,7 +46,6 @@ impl Emoji { } fn return_emojis(&self, string: &str) -> Vec { - let mut emojis: Vec = Vec::new(); let mut current = EmojiHandle { @@ -56,19 +55,21 @@ impl Emoji { for c in string.chars() { - if self.is_emoji(&c) { - if current.symbol == c { - current.count = current.count + 1; - - } else { - if current.count > 0 { - emojis.push(current); - } - - current = EmojiHandle { - symbol: c, - count: 1, - } + if !self.is_emoji(&c) { + continue; + } + + if current.symbol == c { + current.count += 1; + + } else { + if current.count > 0 { + emojis.push(current); + } + + current = EmojiHandle { + symbol: c, + count: 1, } } } -- cgit v1.2.3-70-g09d2