#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum GeometricShapes {
BlackSquare,
WhiteSquare,
WhiteSquareWithRoundedCorners,
WhiteSquareContainingBlackSmallSquare,
SquareWithHorizontalFill,
SquareWithVerticalFill,
SquareWithOrthogonalCrosshatchFill,
SquareWithUpperLeftToLowerRightFill,
SquareWithUpperRightToLowerLeftFill,
SquareWithDiagonalCrosshatchFill,
BlackSmallSquare,
WhiteSmallSquare,
BlackRectangle,
WhiteRectangle,
BlackVerticalRectangle,
WhiteVerticalRectangle,
BlackParallelogram,
WhiteParallelogram,
BlackUpDashPointingTriangle,
WhiteUpDashPointingTriangle,
BlackUpDashPointingSmallTriangle,
WhiteUpDashPointingSmallTriangle,
BlackRightDashPointingTriangle,
WhiteRightDashPointingTriangle,
BlackRightDashPointingSmallTriangle,
WhiteRightDashPointingSmallTriangle,
BlackRightDashPointingPointer,
WhiteRightDashPointingPointer,
BlackDownDashPointingTriangle,
WhiteDownDashPointingTriangle,
BlackDownDashPointingSmallTriangle,
WhiteDownDashPointingSmallTriangle,
BlackLeftDashPointingTriangle,
WhiteLeftDashPointingTriangle,
BlackLeftDashPointingSmallTriangle,
WhiteLeftDashPointingSmallTriangle,
BlackLeftDashPointingPointer,
WhiteLeftDashPointingPointer,
BlackDiamond,
WhiteDiamond,
WhiteDiamondContainingBlackSmallDiamond,
Fisheye,
Lozenge,
WhiteCircle,
DottedCircle,
CircleWithVerticalFill,
Bullseye,
BlackCircle,
CircleWithLeftHalfBlack,
CircleWithRightHalfBlack,
CircleWithLowerHalfBlack,
CircleWithUpperHalfBlack,
CircleWithUpperRightQuadrantBlack,
CircleWithAllButUpperLeftQuadrantBlack,
LeftHalfBlackCircle,
RightHalfBlackCircle,
InverseBullet,
InverseWhiteCircle,
UpperHalfInverseWhiteCircle,
LowerHalfInverseWhiteCircle,
UpperLeftQuadrantCircularArc,
UpperRightQuadrantCircularArc,
LowerRightQuadrantCircularArc,
LowerLeftQuadrantCircularArc,
UpperHalfCircle,
LowerHalfCircle,
BlackLowerRightTriangle,
BlackLowerLeftTriangle,
BlackUpperLeftTriangle,
BlackUpperRightTriangle,
WhiteBullet,
SquareWithLeftHalfBlack,
SquareWithRightHalfBlack,
SquareWithUpperLeftDiagonalHalfBlack,
SquareWithLowerRightDiagonalHalfBlack,
WhiteSquareWithVerticalBisectingLine,
WhiteUpDashPointingTriangleWithDot,
UpDashPointingTriangleWithLeftHalfBlack,
UpDashPointingTriangleWithRightHalfBlack,
LargeCircle,
WhiteSquareWithUpperLeftQuadrant,
WhiteSquareWithLowerLeftQuadrant,
WhiteSquareWithLowerRightQuadrant,
WhiteSquareWithUpperRightQuadrant,
WhiteCircleWithUpperLeftQuadrant,
WhiteCircleWithLowerLeftQuadrant,
WhiteCircleWithLowerRightQuadrant,
WhiteCircleWithUpperRightQuadrant,
UpperLeftTriangle,
UpperRightTriangle,
LowerLeftTriangle,
WhiteMediumSquare,
BlackMediumSquare,
WhiteMediumSmallSquare,
BlackMediumSmallSquare,
}
impl Into<char> for GeometricShapes {
fn into(self) -> char {
match self {
GeometricShapes::BlackSquare => '■',
GeometricShapes::WhiteSquare => '□',
GeometricShapes::WhiteSquareWithRoundedCorners => '▢',
GeometricShapes::WhiteSquareContainingBlackSmallSquare => '▣',
GeometricShapes::SquareWithHorizontalFill => '▤',
GeometricShapes::SquareWithVerticalFill => '▥',
GeometricShapes::SquareWithOrthogonalCrosshatchFill => '▦',
GeometricShapes::SquareWithUpperLeftToLowerRightFill => '▧',
GeometricShapes::SquareWithUpperRightToLowerLeftFill => '▨',
GeometricShapes::SquareWithDiagonalCrosshatchFill => '▩',
GeometricShapes::BlackSmallSquare => '▪',
GeometricShapes::WhiteSmallSquare => '▫',
GeometricShapes::BlackRectangle => '▬',
GeometricShapes::WhiteRectangle => '▭',
GeometricShapes::BlackVerticalRectangle => '▮',
GeometricShapes::WhiteVerticalRectangle => '▯',
GeometricShapes::BlackParallelogram => '▰',
GeometricShapes::WhiteParallelogram => '▱',
GeometricShapes::BlackUpDashPointingTriangle => '▲',
GeometricShapes::WhiteUpDashPointingTriangle => '△',
GeometricShapes::BlackUpDashPointingSmallTriangle => '▴',
GeometricShapes::WhiteUpDashPointingSmallTriangle => '▵',
GeometricShapes::BlackRightDashPointingTriangle => '▶',
GeometricShapes::WhiteRightDashPointingTriangle => '▷',
GeometricShapes::BlackRightDashPointingSmallTriangle => '▸',
GeometricShapes::WhiteRightDashPointingSmallTriangle => '▹',
GeometricShapes::BlackRightDashPointingPointer => '►',
GeometricShapes::WhiteRightDashPointingPointer => '▻',
GeometricShapes::BlackDownDashPointingTriangle => '▼',
GeometricShapes::WhiteDownDashPointingTriangle => '▽',
GeometricShapes::BlackDownDashPointingSmallTriangle => '▾',
GeometricShapes::WhiteDownDashPointingSmallTriangle => '▿',
GeometricShapes::BlackLeftDashPointingTriangle => '◀',
GeometricShapes::WhiteLeftDashPointingTriangle => '◁',
GeometricShapes::BlackLeftDashPointingSmallTriangle => '◂',
GeometricShapes::WhiteLeftDashPointingSmallTriangle => '◃',
GeometricShapes::BlackLeftDashPointingPointer => '◄',
GeometricShapes::WhiteLeftDashPointingPointer => '◅',
GeometricShapes::BlackDiamond => '◆',
GeometricShapes::WhiteDiamond => '◇',
GeometricShapes::WhiteDiamondContainingBlackSmallDiamond => '◈',
GeometricShapes::Fisheye => '◉',
GeometricShapes::Lozenge => '◊',
GeometricShapes::WhiteCircle => '○',
GeometricShapes::DottedCircle => '◌',
GeometricShapes::CircleWithVerticalFill => '◍',
GeometricShapes::Bullseye => '◎',
GeometricShapes::BlackCircle => '●',
GeometricShapes::CircleWithLeftHalfBlack => '◐',
GeometricShapes::CircleWithRightHalfBlack => '◑',
GeometricShapes::CircleWithLowerHalfBlack => '◒',
GeometricShapes::CircleWithUpperHalfBlack => '◓',
GeometricShapes::CircleWithUpperRightQuadrantBlack => '◔',
GeometricShapes::CircleWithAllButUpperLeftQuadrantBlack => '◕',
GeometricShapes::LeftHalfBlackCircle => '◖',
GeometricShapes::RightHalfBlackCircle => '◗',
GeometricShapes::InverseBullet => '◘',
GeometricShapes::InverseWhiteCircle => '◙',
GeometricShapes::UpperHalfInverseWhiteCircle => '◚',
GeometricShapes::LowerHalfInverseWhiteCircle => '◛',
GeometricShapes::UpperLeftQuadrantCircularArc => '◜',
GeometricShapes::UpperRightQuadrantCircularArc => '◝',
GeometricShapes::LowerRightQuadrantCircularArc => '◞',
GeometricShapes::LowerLeftQuadrantCircularArc => '◟',
GeometricShapes::UpperHalfCircle => '◠',
GeometricShapes::LowerHalfCircle => '◡',
GeometricShapes::BlackLowerRightTriangle => '◢',
GeometricShapes::BlackLowerLeftTriangle => '◣',
GeometricShapes::BlackUpperLeftTriangle => '◤',
GeometricShapes::BlackUpperRightTriangle => '◥',
GeometricShapes::WhiteBullet => '◦',
GeometricShapes::SquareWithLeftHalfBlack => '◧',
GeometricShapes::SquareWithRightHalfBlack => '◨',
GeometricShapes::SquareWithUpperLeftDiagonalHalfBlack => '◩',
GeometricShapes::SquareWithLowerRightDiagonalHalfBlack => '◪',
GeometricShapes::WhiteSquareWithVerticalBisectingLine => '◫',
GeometricShapes::WhiteUpDashPointingTriangleWithDot => '◬',
GeometricShapes::UpDashPointingTriangleWithLeftHalfBlack => '◭',
GeometricShapes::UpDashPointingTriangleWithRightHalfBlack => '◮',
GeometricShapes::LargeCircle => '◯',
GeometricShapes::WhiteSquareWithUpperLeftQuadrant => '◰',
GeometricShapes::WhiteSquareWithLowerLeftQuadrant => '◱',
GeometricShapes::WhiteSquareWithLowerRightQuadrant => '◲',
GeometricShapes::WhiteSquareWithUpperRightQuadrant => '◳',
GeometricShapes::WhiteCircleWithUpperLeftQuadrant => '◴',
GeometricShapes::WhiteCircleWithLowerLeftQuadrant => '◵',
GeometricShapes::WhiteCircleWithLowerRightQuadrant => '◶',
GeometricShapes::WhiteCircleWithUpperRightQuadrant => '◷',
GeometricShapes::UpperLeftTriangle => '◸',
GeometricShapes::UpperRightTriangle => '◹',
GeometricShapes::LowerLeftTriangle => '◺',
GeometricShapes::WhiteMediumSquare => '◻',
GeometricShapes::BlackMediumSquare => '◼',
GeometricShapes::WhiteMediumSmallSquare => '◽',
GeometricShapes::BlackMediumSmallSquare => '◾',
}
}
}
impl std::convert::TryFrom<char> for GeometricShapes {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'■' => Ok(GeometricShapes::BlackSquare),
'□' => Ok(GeometricShapes::WhiteSquare),
'▢' => Ok(GeometricShapes::WhiteSquareWithRoundedCorners),
'▣' => Ok(GeometricShapes::WhiteSquareContainingBlackSmallSquare),
'▤' => Ok(GeometricShapes::SquareWithHorizontalFill),
'▥' => Ok(GeometricShapes::SquareWithVerticalFill),
'▦' => Ok(GeometricShapes::SquareWithOrthogonalCrosshatchFill),
'▧' => Ok(GeometricShapes::SquareWithUpperLeftToLowerRightFill),
'▨' => Ok(GeometricShapes::SquareWithUpperRightToLowerLeftFill),
'▩' => Ok(GeometricShapes::SquareWithDiagonalCrosshatchFill),
'▪' => Ok(GeometricShapes::BlackSmallSquare),
'▫' => Ok(GeometricShapes::WhiteSmallSquare),
'▬' => Ok(GeometricShapes::BlackRectangle),
'▭' => Ok(GeometricShapes::WhiteRectangle),
'▮' => Ok(GeometricShapes::BlackVerticalRectangle),
'▯' => Ok(GeometricShapes::WhiteVerticalRectangle),
'▰' => Ok(GeometricShapes::BlackParallelogram),
'▱' => Ok(GeometricShapes::WhiteParallelogram),
'▲' => Ok(GeometricShapes::BlackUpDashPointingTriangle),
'△' => Ok(GeometricShapes::WhiteUpDashPointingTriangle),
'▴' => Ok(GeometricShapes::BlackUpDashPointingSmallTriangle),
'▵' => Ok(GeometricShapes::WhiteUpDashPointingSmallTriangle),
'▶' => Ok(GeometricShapes::BlackRightDashPointingTriangle),
'▷' => Ok(GeometricShapes::WhiteRightDashPointingTriangle),
'▸' => Ok(GeometricShapes::BlackRightDashPointingSmallTriangle),
'▹' => Ok(GeometricShapes::WhiteRightDashPointingSmallTriangle),
'►' => Ok(GeometricShapes::BlackRightDashPointingPointer),
'▻' => Ok(GeometricShapes::WhiteRightDashPointingPointer),
'▼' => Ok(GeometricShapes::BlackDownDashPointingTriangle),
'▽' => Ok(GeometricShapes::WhiteDownDashPointingTriangle),
'▾' => Ok(GeometricShapes::BlackDownDashPointingSmallTriangle),
'▿' => Ok(GeometricShapes::WhiteDownDashPointingSmallTriangle),
'◀' => Ok(GeometricShapes::BlackLeftDashPointingTriangle),
'◁' => Ok(GeometricShapes::WhiteLeftDashPointingTriangle),
'◂' => Ok(GeometricShapes::BlackLeftDashPointingSmallTriangle),
'◃' => Ok(GeometricShapes::WhiteLeftDashPointingSmallTriangle),
'◄' => Ok(GeometricShapes::BlackLeftDashPointingPointer),
'◅' => Ok(GeometricShapes::WhiteLeftDashPointingPointer),
'◆' => Ok(GeometricShapes::BlackDiamond),
'◇' => Ok(GeometricShapes::WhiteDiamond),
'◈' => Ok(GeometricShapes::WhiteDiamondContainingBlackSmallDiamond),
'◉' => Ok(GeometricShapes::Fisheye),
'◊' => Ok(GeometricShapes::Lozenge),
'○' => Ok(GeometricShapes::WhiteCircle),
'◌' => Ok(GeometricShapes::DottedCircle),
'◍' => Ok(GeometricShapes::CircleWithVerticalFill),
'◎' => Ok(GeometricShapes::Bullseye),
'●' => Ok(GeometricShapes::BlackCircle),
'◐' => Ok(GeometricShapes::CircleWithLeftHalfBlack),
'◑' => Ok(GeometricShapes::CircleWithRightHalfBlack),
'◒' => Ok(GeometricShapes::CircleWithLowerHalfBlack),
'◓' => Ok(GeometricShapes::CircleWithUpperHalfBlack),
'◔' => Ok(GeometricShapes::CircleWithUpperRightQuadrantBlack),
'◕' => Ok(GeometricShapes::CircleWithAllButUpperLeftQuadrantBlack),
'◖' => Ok(GeometricShapes::LeftHalfBlackCircle),
'◗' => Ok(GeometricShapes::RightHalfBlackCircle),
'◘' => Ok(GeometricShapes::InverseBullet),
'◙' => Ok(GeometricShapes::InverseWhiteCircle),
'◚' => Ok(GeometricShapes::UpperHalfInverseWhiteCircle),
'◛' => Ok(GeometricShapes::LowerHalfInverseWhiteCircle),
'◜' => Ok(GeometricShapes::UpperLeftQuadrantCircularArc),
'◝' => Ok(GeometricShapes::UpperRightQuadrantCircularArc),
'◞' => Ok(GeometricShapes::LowerRightQuadrantCircularArc),
'◟' => Ok(GeometricShapes::LowerLeftQuadrantCircularArc),
'◠' => Ok(GeometricShapes::UpperHalfCircle),
'◡' => Ok(GeometricShapes::LowerHalfCircle),
'◢' => Ok(GeometricShapes::BlackLowerRightTriangle),
'◣' => Ok(GeometricShapes::BlackLowerLeftTriangle),
'◤' => Ok(GeometricShapes::BlackUpperLeftTriangle),
'◥' => Ok(GeometricShapes::BlackUpperRightTriangle),
'◦' => Ok(GeometricShapes::WhiteBullet),
'◧' => Ok(GeometricShapes::SquareWithLeftHalfBlack),
'◨' => Ok(GeometricShapes::SquareWithRightHalfBlack),
'◩' => Ok(GeometricShapes::SquareWithUpperLeftDiagonalHalfBlack),
'◪' => Ok(GeometricShapes::SquareWithLowerRightDiagonalHalfBlack),
'◫' => Ok(GeometricShapes::WhiteSquareWithVerticalBisectingLine),
'◬' => Ok(GeometricShapes::WhiteUpDashPointingTriangleWithDot),
'◭' => Ok(GeometricShapes::UpDashPointingTriangleWithLeftHalfBlack),
'◮' => Ok(GeometricShapes::UpDashPointingTriangleWithRightHalfBlack),
'◯' => Ok(GeometricShapes::LargeCircle),
'◰' => Ok(GeometricShapes::WhiteSquareWithUpperLeftQuadrant),
'◱' => Ok(GeometricShapes::WhiteSquareWithLowerLeftQuadrant),
'◲' => Ok(GeometricShapes::WhiteSquareWithLowerRightQuadrant),
'◳' => Ok(GeometricShapes::WhiteSquareWithUpperRightQuadrant),
'◴' => Ok(GeometricShapes::WhiteCircleWithUpperLeftQuadrant),
'◵' => Ok(GeometricShapes::WhiteCircleWithLowerLeftQuadrant),
'◶' => Ok(GeometricShapes::WhiteCircleWithLowerRightQuadrant),
'◷' => Ok(GeometricShapes::WhiteCircleWithUpperRightQuadrant),
'◸' => Ok(GeometricShapes::UpperLeftTriangle),
'◹' => Ok(GeometricShapes::UpperRightTriangle),
'◺' => Ok(GeometricShapes::LowerLeftTriangle),
'◻' => Ok(GeometricShapes::WhiteMediumSquare),
'◼' => Ok(GeometricShapes::BlackMediumSquare),
'◽' => Ok(GeometricShapes::WhiteMediumSmallSquare),
'◾' => Ok(GeometricShapes::BlackMediumSmallSquare),
_ => Err(()),
}
}
}
impl Into<u32> for GeometricShapes {
fn into(self) -> u32 {
let c: char = self.into();
let hex = c
.escape_unicode()
.to_string()
.replace("\\u{", "")
.replace("}", "");
u32::from_str_radix(&hex, 16).unwrap()
}
}
impl std::convert::TryFrom<u32> for GeometricShapes {
type Error = ();
fn try_from(u: u32) -> Result<Self, Self::Error> {
if let Ok(c) = char::try_from(u) {
Self::try_from(c)
} else {
Err(())
}
}
}
impl Iterator for GeometricShapes {
type Item = Self;
fn next(&mut self) -> Option<Self> {
let index: u32 = (*self).into();
use std::convert::TryFrom;
Self::try_from(index + 1).ok()
}
}
impl GeometricShapes {
pub fn new() -> Self {
GeometricShapes::BlackSquare
}
pub fn name(&self) -> String {
let s = std::format!("GeometricShapes{:#?}", self);
string_morph::to_sentence_case(&s)
}
}