Skip to content

Commit

Permalink
impl From<char> for ReactionType
Browse files Browse the repository at this point in the history
This can be used as a helpful shortcut for reactions.
  • Loading branch information
Zeyla Hellyer committed May 28, 2017
1 parent e033ff3 commit 2afab7c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/model/channel/reaction.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 2afab7c

Please sign in to comment.