use std::fmt::{Display, Formatter, Result};
#[cfg(feature = "iter")]
use strum_macros::EnumIter;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Emoji {
Person(Person, SkinTone, Gender),
Creature(Creature),
Location(Location),
Item(Item),
}
impl Default for Emoji {
fn default() -> Self {
Self::Person(Default::default(), Default::default(), Default::default())
}
}
impl Display for Emoji {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
Emoji::Person(person, skin, gender) => {
const ZWJ: char = '\u{200d}';
const VARIATION_SELECTOR_16: char = '\u{fe0f}';
let mut buffer = person.to_string();
if gender != &Gender::Neutral {
buffer.push(ZWJ);
buffer.push_str(&gender.to_string());
}
if skin != &SkinTone::Neutral {
buffer.push(ZWJ);
buffer.push_str(&skin.to_string());
}
if gender != &Gender::Neutral || skin != &SkinTone::Neutral {
buffer.push(VARIATION_SELECTOR_16);
}
write!(f, "{}", buffer)?;
}
Emoji::Creature(creature) => write!(f, "{}", creature)?,
Emoji::Location(location) => write!(f, "{}", location)?,
Emoji::Item(item) => write!(f, "{}", item)?,
};
Ok(())
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Person {
Artist,
Baby,
BaldPerson,
BeardedPerson,
Child,
Fairy,
Elf,
Genie,
HeardScarfPerson,
Mage,
MerPerson,
OldPerson,
#[default]
Person,
Royalty,
SkullCapPerson,
TurbanPerson,
Vampire,
Zombie,
}
impl Display for Person {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::Artist => "🧑🎨",
Self::Baby => "👶",
Self::BaldPerson => "🧑🦲",
Self::BeardedPerson => "🧔",
Self::Child => "🧒",
Self::Elf => "🧝",
Self::Fairy => "🧚",
Self::Genie => "🧞",
Self::HeardScarfPerson => "🧕",
Self::Mage => "🧙",
Self::MerPerson => "🧜",
Self::OldPerson => "🧓",
Self::Person => "🧑",
Self::Royalty => "🤴",
Self::SkullCapPerson => "👲",
Self::TurbanPerson => "👳",
Self::Vampire => "🧛",
Self::Zombie => "🧟",
}
)
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum SkinTone {
#[default]
Neutral,
Light,
MediumLight,
Medium,
MediumDark,
Dark,
}
impl Display for SkinTone {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::Neutral => "",
Self::Light => "🏻",
Self::MediumLight => "🏼",
Self::Medium => "🏽",
Self::MediumDark => "🏾",
Self::Dark => "🏿",
}
)
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Gender {
#[default]
Neutral,
Male,
Female,
}
impl Display for Gender {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Gender::Neutral => "",
Gender::Male => "♂",
Gender::Female => "♀",
}
)
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Creature {
#[default]
Ant,
Bat,
Beetle,
Bison,
Boar,
Bug,
Butterfly,
Camel,
Cat,
Cockroach,
Cow,
Crab,
Crocodile,
Deer,
Dog,
Dragon,
Eagle,
Elephant,
Fish,
Ghost,
Goat,
Goblin,
Honeybee,
Horse,
Leopard,
Llama,
Mammoth,
Mouse,
Ogre,
Pig,
Rabbit,
Ram,
Rat,
Rhinoceros,
Scorpion,
Shark,
Snake,
Spider,
Tiger,
TropicalFish,
WaterBuffalo,
Wolf,
}
impl Display for Creature {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::Ant => "🐜",
Self::Bat => "🦇",
Self::Beetle => "🐞",
Self::Bison => "🦬",
Self::Boar => "🐗",
Self::Bug => "🐛",
Self::Butterfly => "🦋",
Self::Camel => "🐫",
Self::Cat => "🐈",
Self::Cockroach => "🪳",
Self::Cow => "🐄",
Self::Crab => "🦀",
Self::Crocodile => "🐊",
Self::Deer => "🦌",
Self::Dog => "🐕",
Self::Dragon => "🐉",
Self::Eagle => "🦅",
Self::Elephant => "🐘",
Self::Fish => "🐟",
Self::Ghost => "👻",
Self::Goat => "🐐",
Self::Goblin => "👺",
Self::Honeybee => "🐝",
Self::Horse => "🐎",
Self::Leopard => "🐆",
Self::Llama => "🦙",
Self::Mammoth => "🦣",
Self::Mouse => "🐁",
Self::Ogre => "👹",
Self::Pig => "🐖",
Self::Rabbit => "🐇",
Self::Ram => "🐏",
Self::Rat => "🐀",
Self::Rhinoceros => "🦏",
Self::Scorpion => "🦂",
Self::Shark => "🦈",
Self::Snake => "🐍",
Self::Spider => "🕷",
Self::Tiger => "🐅",
Self::TropicalFish => "🐠",
Self::WaterBuffalo => "🐃",
Self::Wolf => "🐺",
}
)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Location {
BoatSail,
BuildingClassic,
Campsite,
Canoe,
Castle,
CastleJapanese,
Cave,
Desert,
Hut,
Mountain,
MountainSnow,
Oasis,
Palace,
Tent,
TreeDeciduous,
TreeEvergreen,
TreePalm,
Volcano,
}
impl Display for Location {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::BoatSail => "⛵",
Self::BuildingClassic => "🏛",
Self::Campsite => "🏕",
Self::Canoe => "🛶",
Self::Castle => "🏰",
Self::CastleJapanese => "🏯",
Self::Cave => "🕳",
Self::Desert => "🏜",
Self::Hut => "🛖",
Self::Mountain => "⛰",
Self::MountainSnow => "🏔",
Self::Oasis => "🏜",
Self::Palace => "🏯",
Self::Tent => "⛺",
Self::TreeDeciduous => "🌳",
Self::TreeEvergreen => "🌲",
Self::TreePalm => "🌴",
Self::Volcano => "🌋",
}
)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Item {
Amulet,
Axe,
Bag,
Bandage,
Bed,
Beer,
BloodDrop,
Bomb,
BookClosed,
BookOpen,
Boomerang,
BowAndArrow,
Brick,
Candle,
Coat,
Coffin,
Coin,
Crown,
CrystalBall,
Dagger,
Dart,
Door,
FlagBlack,
FlagTriangle,
Firecracker,
GemStone,
Grave,
Hammer,
HammerAndPick,
HeartRed,
HourglassDone,
HourglassNotDone,
Jar,
Key,
Leaf,
LeafFallen,
LeafMaple,
Map,
MeatOnBone,
MeatCut,
Pick,
PoultryLeg,
PrayerBeads,
RedEnvelope,
RedLantern,
Rock,
Scroll,
Shield,
SwordsCrossed,
Trident,
Urn,
Wand,
WaterDrop,
}
impl Display for Item {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::Amulet => "🧿",
Self::Axe => "🪓",
Self::Bag => "🎒",
Self::Bandage => "🩹",
Self::Bed => "🛏",
Self::Beer => "🍺",
Self::BloodDrop => "🩸",
Self::Bomb => "💣",
Self::BookClosed => "📕",
Self::BookOpen => "📖",
Self::Boomerang => "🪃",
Self::BowAndArrow => "🏹",
Self::Brick => "🧱",
Self::Candle => "🕯",
Self::Coat => "🧥",
Self::Coffin => "⚰️",
Self::Coin => "🪙",
Self::Crown => "👑",
Self::CrystalBall => "🔮",
Self::Dagger => "🗡",
Self::Dart => "🎯",
Self::Door => "🚪",
Self::FlagBlack => "🏴",
Self::FlagTriangle => "🚩",
Self::Firecracker => "🧨",
Self::GemStone => "💎",
Self::Grave => "🪦",
Self::Hammer => "🔨",
Self::HammerAndPick => "⚒️",
Self::HeartRed => "❤️",
Self::HourglassDone => "⌛",
Self::HourglassNotDone => "⏳",
Self::Jar => "🏺",
Self::Key => "🗝️",
Self::Leaf => "🍃",
Self::LeafFallen => "🍂",
Self::LeafMaple => "🍁",
Self::Map => "🗺",
Self::MeatOnBone => "🍖",
Self::MeatCut => "🥩",
Self::Pick => "⛏",
Self::PoultryLeg => "🍗",
Self::PrayerBeads => "📿",
Self::RedEnvelope => "🧧",
Self::RedLantern => "🏮",
Self::Rock => "🪨",
Self::Scroll => "📜",
Self::Shield => "🛡",
Self::SwordsCrossed => "⚔️",
Self::Trident => "🔱",
Self::Urn => "⚱️",
Self::Wand => "🪄",
Self::WaterDrop => "💧",
}
)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "iter", derive(EnumIter))]
pub enum Symbol {
Anger,
Comet,
Cyclone,
Fire,
Electricity,
ExclamationDouble,
ExclamationWithQuestion,
ExclamationRed,
ExclamationWhite,
GenderFemale,
GenderMale,
QuestionRed,
QuestionWhite,
Sparkles,
SpeechBubble,
SpeechBubbleAngry,
Snowflake,
Zzz,
}
impl Display for Symbol {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{}",
match self {
Self::Anger => "💢",
Self::Comet => "☄️",
Self::Cyclone => "🌀",
Self::Fire => "🔥",
Self::Electricity => "⚡",
Self::ExclamationDouble => "‼️",
Self::ExclamationWithQuestion => "⁉️",
Self::ExclamationRed => "❗",
Self::ExclamationWhite => "❕",
Self::GenderFemale => "♀️",
Self::GenderMale => "♂️",
Self::QuestionRed => "❓",
Self::QuestionWhite => "❔",
Self::Sparkles => "✨",
Self::SpeechBubble => "💬",
Self::SpeechBubbleAngry => "🗯️",
Self::Snowflake => "❄️",
Self::Zzz => "💤",
}
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_item() {
assert_eq!(Item::Amulet.to_string(), "🧿");
assert_eq!(Item::Axe.to_string(), "🪓");
assert_eq!(Item::Bag.to_string(), "🎒");
assert_eq!(Item::Bandage.to_string(), "🩹");
assert_eq!(Item::Bed.to_string(), "🛏");
assert_eq!(Item::Beer.to_string(), "🍺");
assert_eq!(Item::BloodDrop.to_string(), "🩸");
assert_eq!(Item::Bomb.to_string(), "💣");
assert_eq!(Item::BookClosed.to_string(), "📕");
assert_eq!(Item::BookOpen.to_string(), "📖");
assert_eq!(Item::Boomerang.to_string(), "🪃");
assert_eq!(Item::BowAndArrow.to_string(), "🏹");
assert_eq!(Item::Brick.to_string(), "🧱");
assert_eq!(Item::Candle.to_string(), "🕯");
assert_eq!(Item::Coat.to_string(), "🧥");
assert_eq!(Item::Coffin.to_string(), "⚰️");
assert_eq!(Item::Coin.to_string(), "🪙");
assert_eq!(Item::Crown.to_string(), "👑");
assert_eq!(Item::CrystalBall.to_string(), "🔮");
assert_eq!(Item::Dagger.to_string(), "🗡");
assert_eq!(Item::Dart.to_string(), "🎯");
assert_eq!(Item::Door.to_string(), "🚪");
assert_eq!(Item::FlagBlack.to_string(), "🏴");
assert_eq!(Item::FlagTriangle.to_string(), "🚩");
assert_eq!(Item::Firecracker.to_string(), "🧨");
assert_eq!(Item::GemStone.to_string(), "💎");
assert_eq!(Item::Grave.to_string(), "🪦");
assert_eq!(Item::Hammer.to_string(), "🔨");
assert_eq!(Item::HammerAndPick.to_string(), "⚒️");
assert_eq!(Item::HeartRed.to_string(), "❤️");
assert_eq!(Item::HourglassDone.to_string(), "⌛");
assert_eq!(Item::HourglassNotDone.to_string(), "⏳");
assert_eq!(Item::Jar.to_string(), "🏺");
assert_eq!(Item::Key.to_string(), "🗝️");
assert_eq!(Item::Leaf.to_string(), "🍃");
assert_eq!(Item::LeafFallen.to_string(), "🍂");
assert_eq!(Item::LeafMaple.to_string(), "🍁");
assert_eq!(Item::Map.to_string(), "🗺");
assert_eq!(Item::MeatOnBone.to_string(), "🍖");
assert_eq!(Item::MeatCut.to_string(), "🥩");
assert_eq!(Item::Pick.to_string(), "⛏");
assert_eq!(Item::PoultryLeg.to_string(), "🍗");
assert_eq!(Item::PrayerBeads.to_string(), "📿");
assert_eq!(Item::RedEnvelope.to_string(), "🧧");
assert_eq!(Item::RedLantern.to_string(), "🏮");
assert_eq!(Item::Rock.to_string(), "🪨");
assert_eq!(Item::Scroll.to_string(), "📜");
assert_eq!(Item::Shield.to_string(), "🛡");
assert_eq!(Item::SwordsCrossed.to_string(), "⚔️");
assert_eq!(Item::Trident.to_string(), "🔱");
assert_eq!(Item::Urn.to_string(), "⚱️");
assert_eq!(Item::Wand.to_string(), "🪄");
assert_eq!(Item::WaterDrop.to_string(), "💧");
}
#[test]
fn test_symbol() {
assert_eq!(Symbol::Anger.to_string(), "💢");
assert_eq!(Symbol::Comet.to_string(), "☄️");
assert_eq!(Symbol::Cyclone.to_string(), "🌀");
assert_eq!(Symbol::Fire.to_string(), "🔥");
assert_eq!(Symbol::Electricity.to_string(), "⚡");
assert_eq!(Symbol::ExclamationDouble.to_string(), "‼️");
assert_eq!(Symbol::ExclamationWithQuestion.to_string(), "⁉️");
assert_eq!(Symbol::ExclamationRed.to_string(), "❗");
assert_eq!(Symbol::ExclamationWhite.to_string(), "❕");
assert_eq!(Symbol::GenderFemale.to_string(), "♀️");
assert_eq!(Symbol::GenderMale.to_string(), "♂️");
assert_eq!(Symbol::QuestionRed.to_string(), "❓");
assert_eq!(Symbol::QuestionWhite.to_string(), "❔");
assert_eq!(Symbol::Sparkles.to_string(), "✨");
assert_eq!(Symbol::SpeechBubble.to_string(), "💬");
assert_eq!(Symbol::SpeechBubbleAngry.to_string(), "🗯️");
assert_eq!(Symbol::Snowflake.to_string(), "❄️");
assert_eq!(Symbol::Zzz.to_string(), "💤");
}
#[test]
fn test_location() {
assert_eq!(Location::BoatSail.to_string(), "⛵");
assert_eq!(Location::BuildingClassic.to_string(), "🏛");
assert_eq!(Location::Campsite.to_string(), "🏕");
assert_eq!(Location::Canoe.to_string(), "🛶");
assert_eq!(Location::Castle.to_string(), "🏰");
assert_eq!(Location::CastleJapanese.to_string(), "🏯");
assert_eq!(Location::Cave.to_string(), "🕳");
assert_eq!(Location::Desert.to_string(), "🏜");
assert_eq!(Location::Hut.to_string(), "🛖");
assert_eq!(Location::Mountain.to_string(), "⛰");
assert_eq!(Location::MountainSnow.to_string(), "🏔");
assert_eq!(Location::Oasis.to_string(), "🏜");
assert_eq!(Location::Palace.to_string(), "🏯");
assert_eq!(Location::Tent.to_string(), "⛺");
assert_eq!(Location::TreeDeciduous.to_string(), "🌳");
assert_eq!(Location::TreeEvergreen.to_string(), "🌲");
assert_eq!(Location::TreePalm.to_string(), "🌴");
assert_eq!(Location::Volcano.to_string(), "🌋");
}
#[test]
fn test_person() {
assert_eq!(Person::Artist.to_string(), "🧑🎨");
assert_eq!(Person::Baby.to_string(), "👶");
assert_eq!(Person::BaldPerson.to_string(), "🧑🦲");
assert_eq!(Person::BeardedPerson.to_string(), "🧔");
assert_eq!(Person::Child.to_string(), "🧒");
assert_eq!(Person::Elf.to_string(), "🧝");
assert_eq!(Person::Fairy.to_string(), "🧚");
assert_eq!(Person::Genie.to_string(), "🧞");
assert_eq!(Person::HeardScarfPerson.to_string(), "🧕");
assert_eq!(Person::Mage.to_string(), "🧙");
assert_eq!(Person::MerPerson.to_string(), "🧜");
assert_eq!(Person::OldPerson.to_string(), "🧓");
assert_eq!(Person::Person.to_string(), "🧑");
assert_eq!(Person::Royalty.to_string(), "🤴");
assert_eq!(Person::SkullCapPerson.to_string(), "👲");
assert_eq!(Person::TurbanPerson.to_string(), "👳");
assert_eq!(Person::Vampire.to_string(), "🧛");
assert_eq!(Person::Zombie.to_string(), "🧟");
}
#[test]
fn test_creature() {
assert_eq!(Creature::Ant.to_string(), "🐜");
assert_eq!(Creature::Bat.to_string(), "🦇");
assert_eq!(Creature::Beetle.to_string(), "🐞");
assert_eq!(Creature::Bison.to_string(), "🦬");
assert_eq!(Creature::Boar.to_string(), "🐗");
assert_eq!(Creature::Bug.to_string(), "🐛");
assert_eq!(Creature::Butterfly.to_string(), "🦋");
assert_eq!(Creature::Camel.to_string(), "🐫");
assert_eq!(Creature::Cat.to_string(), "🐈");
assert_eq!(Creature::Cockroach.to_string(), "🪳");
assert_eq!(Creature::Cow.to_string(), "🐄");
assert_eq!(Creature::Crab.to_string(), "🦀");
assert_eq!(Creature::Crocodile.to_string(), "🐊");
assert_eq!(Creature::Deer.to_string(), "🦌");
assert_eq!(Creature::Dog.to_string(), "🐕");
assert_eq!(Creature::Dragon.to_string(), "🐉");
assert_eq!(Creature::Eagle.to_string(), "🦅");
assert_eq!(Creature::Elephant.to_string(), "🐘");
assert_eq!(Creature::Fish.to_string(), "🐟");
assert_eq!(Creature::Ghost.to_string(), "👻");
assert_eq!(Creature::Goat.to_string(), "🐐");
assert_eq!(Creature::Goblin.to_string(), "👺");
assert_eq!(Creature::Honeybee.to_string(), "🐝");
assert_eq!(Creature::Horse.to_string(), "🐎");
assert_eq!(Creature::Leopard.to_string(), "🐆");
assert_eq!(Creature::Llama.to_string(), "🦙");
assert_eq!(Creature::Mammoth.to_string(), "🦣");
assert_eq!(Creature::Mouse.to_string(), "🐁");
assert_eq!(Creature::Ogre.to_string(), "👹");
assert_eq!(Creature::Pig.to_string(), "🐖");
assert_eq!(Creature::Rabbit.to_string(), "🐇");
assert_eq!(Creature::Ram.to_string(), "🐏");
assert_eq!(Creature::Rat.to_string(), "🐀");
assert_eq!(Creature::Rhinoceros.to_string(), "🦏");
assert_eq!(Creature::Scorpion.to_string(), "🦂");
assert_eq!(Creature::Shark.to_string(), "🦈");
assert_eq!(Creature::Snake.to_string(), "🐍");
assert_eq!(Creature::Spider.to_string(), "🕷");
assert_eq!(Creature::Tiger.to_string(), "🐅");
assert_eq!(Creature::TropicalFish.to_string(), "🐠");
assert_eq!(Creature::WaterBuffalo.to_string(), "🐃");
assert_eq!(Creature::Wolf.to_string(), "🐺");
}
}