pub enum Direction {
Right = 0,
Up = 1,
Left = 2,
Down = 3,
}Expand description
An axis-parallel direction of travel.
Variants§
Right = 0
Towards larger x.
Up = 1
Towards larger y.
Left = 2
Towards smaller x.
Down = 3
Towards smaller y.
Implementations§
Source§impl Direction
impl Direction
Sourcepub const ALL: [Self; 4]
pub const ALL: [Self; 4]
All four directions, counter-clockwise from Direction::Right.
Sourcepub const fn from_index(i: usize) -> Self
pub const fn from_index(i: usize) -> Self
The direction with index i in Direction::ALL; i is taken modulo 4.
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
The index of this direction in Direction::ALL.
Sourcepub const fn left(self) -> Self
pub const fn left(self) -> Self
The direction after a quarter turn to the left (counter-clockwise).
Sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Whether the direction moves towards larger coordinates.
Trait Implementations§
impl Copy for Direction
impl Eq for Direction
Source§impl Ord for Direction
impl Ord for Direction
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Direction
impl PartialOrd for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Forget for Direction
impl Freeze for Direction
impl Move for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnsafeUnpin 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