Created
February 13, 2018 23:58
-
-
Save anonymous/37154a35c71e520c1a729f361e9b25ab to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
#[derive(Debug, Clone, Copy)] | |
pub enum CardinalPoint { | |
North = 0x2191, // ↑ | |
NorthEast = 0x2197, // ↗ | |
East = 0x2192, // → | |
SouthEast = 0x2198, // ↘ | |
South = 0x2193, // ↓ | |
SouthWest = 0x2199, // ↙ | |
West = 0x2190, // ← | |
NorthWest = 0x2196, // ↖ | |
} | |
impl fmt::Display for CardinalPoint { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
use std::char; | |
write!(f, "{}", char::from_u32(*self as u32).unwrap()) | |
} | |
} | |
fn main() { | |
println!("{}", CardinalPoint::North); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment