Struct emojis::Emoji [−][src]
pub struct Emoji { /* fields omitted */ }
Expand description
Represents an emoji.
See Unicode.org for more information.
Implementations
Returns this emoji as a string.
Examples
let rocket = emojis::lookup("🚀").unwrap();
assert_eq!(rocket.as_str(), "🚀")
Returns the CLDR short name for this emoji.
Examples
let cool = emojis::lookup("😎").unwrap();
assert_eq!(cool.name(), "smiling face with sunglasses");
Returns this emoji’s group.
Examples
let flag = emojis::lookup("🇿🇦").unwrap();
assert_eq!(flag.group(), Group::Flags);
Returns the skin tone of this emoji.
Examples
use emojis::SkinTone;
let peace = emojis::lookup("✌️").unwrap();
assert_eq!(peace.skin_tone(), Some(SkinTone::Default));
let peace = emojis::lookup("✌🏽").unwrap();
assert_eq!(peace.skin_tone(), Some(SkinTone::Medium));
For emojis where skin tones are not applicable this will be None
.
let cool = emojis::lookup("😎").unwrap();
assert!(cool.skin_tone().is_none());
Returns an iterator over the emoji and all the related skin tone emojis.
Examples
use emojis::Emoji;
let luck = emojis::lookup("🤞🏼").unwrap();
let tones: Vec<_> = luck.skin_tones().unwrap().map(Emoji::as_str).collect();
assert_eq!(tones, ["🤞", "🤞🏻", "🤞🏼", "🤞🏽", "🤞🏾", "🤞🏿"]);
For emojis where skin tones are not applicable this will return None
.
let cool = emojis::lookup("😎").unwrap();
assert!(cool.skin_tones().is_none());
Returns a version of this emoji that has the given skin tone.
Examples
use emojis::SkinTone;
let peace = emojis::lookup("🙌🏼")
.unwrap()
.with_skin_tone(SkinTone::MediumDark)
.unwrap();
assert_eq!(peace, emojis::lookup("🙌🏾").unwrap());
For emojis where skin tones are not applicable this will be None
.
use emojis::SkinTone;
let cool = emojis::lookup("😎").unwrap();
assert!(cool.with_skin_tone(SkinTone::Medium).is_none());