pub enum Direction {
Up,
UpRight,
Right,
DownRight,
Down,
DownLeft,
Left,
UpLeft,
}Expand description
A cardinal direction on a Board
Variants§
Implementations§
Source§impl Direction
impl Direction
pub fn from_num(dir: usize) -> Result<Self, ThudError>
Sourcepub fn from_route(start: Coord, end: Coord) -> Result<Direction, ThudError>
pub fn from_route(start: Coord, end: Coord) -> Result<Direction, ThudError>
Use two Coords to get a Direction from one to the other
Returns Err(ThudError::MathError) if:
Sourcepub fn modifier(&self) -> (isize, isize)
pub fn modifier(&self) -> (isize, isize)
Get a tuple representing the changes needed to a Coord in order to “move” it in the
Direction given by self.
Example:
use thud::Direction;
assert_eq!(Direction::Up.modifier(), (0, 1));
assert_eq!(Direction::DownLeft.modifier(), (-1, -1));Trait Implementations§
impl Copy for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Freeze for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnwindSafe for Direction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more