[−][src]Enum thud::Direction
Represents a cardinal direction on a Board
Variants
Methods
impl Direction[src]
pub fn all() -> Vec<Self>[src]
Get a Vec containing all the different possible Directions
pub fn from_route(start: Coord, end: Coord) -> Result<Direction, ThudError>[src]
Use two Coords to get a Direction from one to the other
Returns Err(ThudError::MathError) if:
pub fn modifier(&self) -> (isize, isize)[src]
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));
pub fn modify(&self, loc: Coord) -> Result<Coord, ThudError>[src]
Return a Coord equal to loc offset by one square in the direction given by self.
Returns Err(ThudError::MathError) if this movement would place the Coord out of bounds.
pub fn opposite(&self) -> Self[src]
Get the "opposite" Direction to self.
For example:
use thud::Direction; assert_eq!(Direction::Up.opposite(), Direction::Down);
Trait Implementations
impl Clone for Direction[src]
impl Copy for Direction[src]
impl Debug for Direction[src]
impl PartialEq<Direction> for Direction[src]
impl StructuralPartialEq for Direction[src]
Auto Trait Implementations
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnwindSafe for Direction
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,