pub enum Dir {
N = 0,
NE = 1,
E = 2,
SE = 3,
S = 4,
SW = 5,
W = 6,
NW = 7,
}Expand description
Direction type.
This type represents a relative movement of one square.
It’s a building block for paths, iterating on a super::Pos neighbors,
etc. It effectively represents the edges in a graph, while the
Pos type represents nodes.
Variants§
N = 0
North, or up
NE = 1
Northeast
E = 2
East, or right
SE = 3
Southeast
S = 4
South, or down
SW = 5
Southwest
W = 6
West, or left
NW = 7
Norwest
Implementations§
Source§impl Dir
impl Dir
Sourcepub const ALL8: [Self; 8]
pub const ALL8: [Self; 8]
All 8 possible values in enum order
Used to convert a usize into a Dir value via indexing.
Sourcepub const NAMES_CARDINAL: [&'static str; 8]
pub const NAMES_CARDINAL: [&'static str; 8]
The “cardinal” names of all corresponding Dir values.
Used to convert a Dir value into a &’static str via indexing.
Sourcepub const NAMES_UTF8: [&'static str; 8]
pub const NAMES_UTF8: [&'static str; 8]
The UTF-8 symbol corresponding to Dir values.
Used to convert a Dir value into a &’static str via indexing.
Sourcepub const NAMES_UTF8_CHAR: [char; 8]
pub const NAMES_UTF8_CHAR: [char; 8]
The UTF-8 symbol corresponding to Dir values.
Used to convert a Dir value into a char via indexing.
Sourcepub const NAMES_ASCII: [&'static str; 8]
pub const NAMES_ASCII: [&'static str; 8]
The ASCII symbol corresponding to Dir values.
Used to convert a Dir value into a &’static str via indexing.
Sourcepub const NAMES_ASCII_CHAR: [char; 8]
pub const NAMES_ASCII_CHAR: [char; 8]
The ASCII symbol corresponding to Dir values.
Used to convert a Dir value into a char via indexing.
Sourcepub const fn is_diagonal(&self) -> bool
pub const fn is_diagonal(&self) -> bool
Return true if the Dir is one of the diagonals: NE, SE, SW or NW.
Sourcepub const fn name_cardinal(&self) -> &'static str
pub const fn name_cardinal(&self) -> &'static str
Return the “cardinal” name of the Dir
Sourcepub const fn name_utf8_char(&self) -> char
pub const fn name_utf8_char(&self) -> char
Return the UTF-8 arrow corresponding to the Dir
Sourcepub const fn name_ascii(&self) -> &'static str
pub const fn name_ascii(&self) -> &'static str
Return the UTF-8 arrow corresponding to the Dir
Sourcepub const fn name_ascii_char(&self) -> char
pub const fn name_ascii_char(&self) -> char
Return the UTF-8 arrow corresponding to the Dir
Sourcepub const fn rotate(&self, other: &Dir) -> Dir
pub const fn rotate(&self, other: &Dir) -> Dir
Rotate a Dir using the angle given by the other Dir argument
Trait Implementations§
Source§impl<T: BoundedInt, U: BoundedInt> Add<Dir> for &(T, U)
impl<T: BoundedInt, U: BoundedInt> Add<Dir> for &(T, U)
Source§impl<const XMAX: u16, const YMAX: u16> Add<Dir> for &Pos<XMAX, YMAX>where
(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>): Add<Dir, Output = Result<(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>), Error>>,
impl<const XMAX: u16, const YMAX: u16> Add<Dir> for &Pos<XMAX, YMAX>where
(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>): Add<Dir, Output = Result<(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>), Error>>,
Source§impl<T: BoundedInt, U: BoundedInt> Add<Dir> for (T, U)
impl<T: BoundedInt, U: BoundedInt> Add<Dir> for (T, U)
Source§impl<const XMAX: u16, const YMAX: u16> Add<Dir> for Pos<XMAX, YMAX>where
(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>): Add<Dir, Output = Result<(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>), Error>>,
impl<const XMAX: u16, const YMAX: u16> Add<Dir> for Pos<XMAX, YMAX>where
(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>): Add<Dir, Output = Result<(BoundedU16<0, XMAX>, BoundedU16<0, YMAX>), Error>>,
Source§impl AddAssign for Dir
impl AddAssign for Dir
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read more