diff options
| author | Jokler <jokler.contact@gmail.com> | 2017-10-28 23:34:30 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2017-10-28 23:34:30 +0200 |
| commit | d203f2689ac7addf36a32150691f459212199f09 (patch) | |
| tree | efe7033d4021551629bfd557be883c538cbda535 /src | |
| parent | feafddfde3a42725db8f4d68eb6c6a8e5058ed87 (diff) | |
| download | frippy-d203f2689ac7addf36a32150691f459212199f09.tar.gz frippy-d203f2689ac7addf36a32150691f459212199f09.zip | |
Reformat the emoji counting loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/emoji.rs | 29 |
1 files 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<EmojiHandle> { - let mut emojis: Vec<EmojiHandle> = 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, } } } |
