emojis

Function get

source
pub fn get(s: &str) -> Option<&'static Emoji>
Expand description

Lookup an emoji by Unicode value.

This take Ο(1) time.

§Note

If passed a minimally qualified or unqualified emoji this will return the emoji struct containing the fully qualified version.

§Examples

In the ordinary case.

let emoji = "🚀";
let rocket = emojis::get(emoji).unwrap();
assert!(rocket.as_str() == emoji);
assert_eq!(rocket.shortcode().unwrap(), "rocket");

For a minimally qualified or unqualified emoji.

let unqualified = "\u{1f43f}";
let fully_qualified = "\u{1f43f}\u{fe0f}";
let chipmunk = emojis::get(unqualified).unwrap();
assert_eq!(chipmunk.as_str(), fully_qualified);
assert_eq!(chipmunk.shortcode().unwrap(), "chipmunk");