#[repr(u8)]pub enum Direction {
East = 0,
NorthEast = 1,
North = 2,
NorthWest = 3,
West = 4,
SouthWest = 5,
South = 6,
SouthEast = 7,
}Expand description
An enumeration of compass directions. The traditional “cardinal” directions, along with the “ordinal” ones as well.
We use a counter-clockwise ordering starting at East, so that it aligns well with radian angles.
Variants§
Implementations§
Source§impl Direction
impl Direction
Sourcepub const VALUES: &'static DirectionSet
pub const VALUES: &'static DirectionSet
A reference to the set of all possible Directions.
Sourcepub const CARDINAL: &'static DirectionSet
pub const CARDINAL: &'static DirectionSet
A reference to the set of cardinal Directions.
Sourcepub const ORDINAL: &'static DirectionSet
pub const ORDINAL: &'static DirectionSet
A reference to the set of ordinal Directions.
Sourcepub fn parse(s: &str) -> Option<Direction>
pub fn parse(s: &str) -> Option<Direction>
Parse a string into a Direction.
Both long and full direction names are supported, along with
whitespace, hyphens, and underscores between the intercardinal
direction words.
Sourcepub fn short_name(self) -> &'static str
pub fn short_name(self) -> &'static str
Obtain an abbreviated name for this Direction.
Sourcepub fn is_cardinal(self) -> bool
pub fn is_cardinal(self) -> bool
Is this a cardinal Direction?
Sourcepub fn is_ordinal(self) -> bool
pub fn is_ordinal(self) -> bool
Is this an ordinal Direction?
Sourcepub fn from_u8_checked(value: u8) -> Option<Direction>
pub fn from_u8_checked(value: u8) -> Option<Direction>
Convert a u8 value to an Option<Direction>.
Returns None if the provided value is not in the range 0-7.
Sourcepub fn from_u8(value: u8) -> Direction
pub fn from_u8(value: u8) -> Direction
Convert a u8 value to a Direction. Will panic if the value is
not in the range 0-7.
Sourcepub fn counter_clockwise(self) -> Direction
pub fn counter_clockwise(self) -> Direction
Produce the Direction counter-clockwise from this Direction.