From a6caefb849967324c07cb6d4a3d312a5b18f0fef Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 12 May 2018 16:30:23 +0200 Subject: Emoji: Add default to EmojiHandle --- src/plugins/emoji.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index b50b782..a2337ee 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -11,6 +11,7 @@ use error::FrippyError; use failure::Fail; use failure::ResultExt; +#[derive(Default, Debug)] struct EmojiHandle { symbol: char, count: i32, @@ -44,21 +45,20 @@ impl Emoji { if emojis.is_empty() { None } else { - Some(emojis - .iter() - .map(|e| e.to_string()) - .collect::>() - .join(", ")) + Some( + emojis + .iter() + .map(|e| e.to_string()) + .collect::>() + .join(", "), + ) } } fn return_emojis(&self, string: &str) -> Vec { let mut emojis: Vec = Vec::new(); - let mut current = EmojiHandle { - symbol: ' ', - count: 0, - }; + let mut current = EmojiHandle::default(); for c in string.chars() { if !self.is_emoji(&c) { @@ -107,16 +107,16 @@ impl Plugin for Emoji { match message.command { Command::PRIVMSG(_, ref content) => { if let Some(emojis) = self.emoji(content) { - match client - .send_privmsg(message.response_target().unwrap(), &emojis) - { - Ok(_) => ExecutionStatus::Done, - Err(e) => ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()), + match client.send_privmsg(message.response_target().unwrap(), &emojis) { + Ok(_) => ExecutionStatus::Done, + Err(e) => { + ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()) } + } } else { ExecutionStatus::Done } - }, + } _ => ExecutionStatus::Done, } } -- cgit v1.2.3-70-g09d2