diff options
| author | Zeyla Hellyer <[email protected]> | 2017-05-28 10:08:09 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-28 10:09:12 -0700 |
| commit | 2afab7c6eb828e491721e15f11a76ae36e34796d (patch) | |
| tree | 85f54eedb956a8c35852f9721314041b7b221482 /src/model | |
| parent | Add CurrentUser::invite_url method (diff) | |
| download | serenity-2afab7c6eb828e491721e15f11a76ae36e34796d.tar.xz serenity-2afab7c6eb828e491721e15f11a76ae36e34796d.zip | |
impl From<char> for ReactionType
This can be used as a helpful shortcut for reactions.
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel/reaction.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index fbc02ad..a9d17fa 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -241,6 +241,33 @@ impl ReactionType { } } +impl From<char> for ReactionType { + /// Creates a `ReactionType` from a `char`. + /// + /// # Examples + /// + /// Reacting to a message with an apple: + /// + /// ```rust,no_run + /// # use serenity::model::ChannelId; + /// # use std::error::Error; + /// # + /// # fn try_main() -> Result<(), Box<Error>> { + /// # let message = ChannelId(0).get_message(0)?; + /// # + /// message.react('🍎')?; + /// # Ok(()) + /// # } + /// # + /// # fn main() { + /// # try_main().unwrap(); + /// # } + /// ``` + fn from(ch: char) -> ReactionType { + ReactionType::Unicode(ch.to_string()) + } +} + impl From<Emoji> for ReactionType { fn from(emoji: Emoji) -> ReactionType { ReactionType::Custom { |