Skip to main content

Dir4

Enum Dir4 

Source
pub enum Dir4 {
    Up,
    Down,
    Left,
    Right,
}
Expand description

The four cardinal directions.

Variants§

§

Up

§

Down

§

Left

§

Right

Trait Implementations§

Source§

impl Clone for Dir4

Source§

fn clone(&self) -> Dir4

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Dir4

Source§

impl Debug for Dir4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Direction for Dir4

Source§

fn delta(self) -> (i8, i8)

Returns the (x, y) delta for one unit of the Direction.
Source§

fn rotate_right(self) -> Dir4

Returns a new Direction which represents the given one being rotated “right” or clockwise by one unit.
Source§

fn rotate_left(self) -> Dir4

Returns a new Direction which represents the given one being rotated “left” or counter-clockwise by one unit.
Source§

fn rotate_right_90(self) -> Dir4

Returns a new Direction which represents the given one being rotated “right” or clockwise by 90 degrees.
Source§

fn rotate_left_90(self) -> Dir4

Returns a new Direction which represents the given one being rotated “left” or counter-clockwise by 90 degrees.
Source§

fn opposite(self) -> Dir4

Returns a new Direction which represents the “opposite” of the given one. Can also be seen as rotating the given one by 180 degrees.
Source§

fn iter() -> impl Iterator<Item = Dir4>

Returns an iterator through all values of the Direction, starting with Up and proceeding clockwise.
Source§

fn iter_from(initial_dir: Self) -> impl Iterator<Item = Self>

Returns an iterator through all values of the Direction, starting with the given initial_dir and proceeding clockwise. Read more
Source§

fn iter_valid_usizes_deltas( curr: (usize, usize), size: (usize, usize), ) -> impl Iterator<Item = (usize, usize)>

Similar to apply_delta_to_usizes(), but iterates through all valid directions. A valid direction is defined as any whose result is non-negative and is less than size in the respective dimension. Read more
Source§

fn apply_delta_to_usizes(self, usizes: (usize, usize)) -> (usize, usize)

Takes in a pair of usizes representing (x, y) coordinates, and returns the result of “moving” one unit in the given direction. Can panic (see usizes_plus_i() documentation). Read more
Source§

impl Eq for Dir4

Source§

impl Hash for Dir4

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Dir4

Source§

fn eq(&self, other: &Dir4) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Dir4

Auto Trait Implementations§

§

impl Freeze for Dir4

§

impl RefUnwindSafe for Dir4

§

impl Send for Dir4

§

impl Sync for Dir4

§

impl Unpin for Dir4

§

impl UnsafeUnpin for Dir4

§

impl UnwindSafe for Dir4

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.