Skip to content

Commit

Permalink
Add a helper method for comparing unicode reaction emojis (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Th3-M4jor authored and arqunis committed Dec 2, 2020
1 parent 6e39727 commit 0de77e7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/model/channel/reaction.rs
Expand Up @@ -378,6 +378,20 @@ impl ReactionType {
ReactionType::Unicode(ref unicode) => unicode.clone(),
}
}

/// Helper function to allow comparing unicode emojis without having to
/// perform any allocation. Will always return false if the reaction was
/// not a unicode reaction.
pub fn unicode_eq(&self, other: &str) -> bool {

if let ReactionType::Unicode(unicode) = &self {
unicode == other
} else {
// Always return false if not a unicode reaction
false
}

}
}

impl From<char> for ReactionType {
Expand Down

0 comments on commit 0de77e7

Please sign in to comment.