pub struct Emoji { /* private fields */ }Expand description
Represents an emoji.
See Unicode.org for more information.
Implementations
sourceimpl Emoji
impl Emoji
sourcepub const fn as_str(&self) -> &str
pub const fn as_str(&self) -> &str
Returns this emoji as a string.
Examples
let rocket = emojis::lookup("🚀").unwrap();
assert_eq!(rocket.as_str(), "🚀")sourcepub const fn name(&self) -> &str
pub const fn name(&self) -> &str
Returns the CLDR short name for this emoji.
Examples
let cool = emojis::lookup("😎").unwrap();
assert_eq!(cool.name(), "smiling face with sunglasses");sourcepub const fn unicode_version(&self) -> UnicodeVersion
pub const fn unicode_version(&self) -> UnicodeVersion
Returns the Unicode version this emoji first appeared in.
Examples
use emojis::UnicodeVersion;
let villain = emojis::lookup("🦹").unwrap();
assert_eq!(villain.unicode_version(), UnicodeVersion::new(11, 0));sourcepub const fn group(&self) -> Group
pub const fn group(&self) -> Group
Returns this emoji’s group.
Examples
use emojis::Group;
let flag = emojis::lookup("🇿🇦").unwrap();
assert_eq!(flag.group(), Group::Flags);sourcepub fn skin_tone(&self) -> Option<SkinTone>
pub fn skin_tone(&self) -> Option<SkinTone>
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());sourcepub fn skin_tones(&self) -> Option<impl Iterator<Item = &'static Self>>
pub fn skin_tones(&self) -> Option<impl Iterator<Item = &'static Self>>
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());sourcepub fn with_skin_tone(&self, skin_tone: SkinTone) -> Option<&'static Self>
pub fn with_skin_tone(&self, skin_tone: SkinTone) -> Option<&'static Self>
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());Trait Implementations
impl Eq for Emoji
Auto Trait Implementations
impl RefUnwindSafe for Emoji
impl Send for Emoji
impl Sync for Emoji
impl Unpin for Emoji
impl UnwindSafe for Emoji
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more