diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-05-12 16:30:23 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-05-12 16:30:23 +0200 |
| commit | a6caefb849967324c07cb6d4a3d312a5b18f0fef (patch) | |
| tree | 4eaac23e9f4e7116d08c03ab5f6a10973a0c5201 /src | |
| parent | 6ec0c444f642630485ca18b3043191b67a6f8e8c (diff) | |
| download | frippy-a6caefb849967324c07cb6d4a3d312a5b18f0fef.tar.gz frippy-a6caefb849967324c07cb6d4a3d312a5b18f0fef.zip | |
Emoji: Add default to EmojiHandle
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/emoji.rs | 30 |
1 files 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::<Vec<String>>() - .join(", ")) + Some( + emojis + .iter() + .map(|e| e.to_string()) + .collect::<Vec<String>>() + .join(", "), + ) } } fn return_emojis(&self, string: &str) -> Vec<EmojiHandle> { let mut emojis: Vec<EmojiHandle> = 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, } } |
