Enum gridly::prelude::Rotation

source ·
pub enum Rotation {
    None = 0,
    Clockwise = 1,
    Flip = 2,
    Anticlockwise = 3,
}
Expand description

The 4 cardinal rotations: None (no rotation), Flip, Clockwise, and Anticlockwise. These rotations support basic arithmetic operations with themselves (sums, multiplication by a factor, etc) and can be applied to Direction and Vector.

Variants§

§

None = 0

No rotation (0°)

§

Clockwise = 1

Rotate 90° clockwise

§

Flip = 2

Rotate 180°

§

Anticlockwise = 3

Rotate 90° anticlockwise

Implementations§

source§

impl Rotation

source

pub fn is_turn(self) -> bool

Check if a rotation is a turn; that is, if it is Clockwise or Anticlockwise

Example
use gridly::rotation::*;

assert!(!Rotation::None.is_turn());
assert!(!Rotation::Flip.is_turn());
assert!(Clockwise.is_turn());
assert!(Anticlockwise.is_turn());
source

pub fn reverse(self) -> Self

Get the rotation in the opposite direction. Note that Rotation::None and Rotation::Flip are their own opposites.

Example
use gridly::rotation::*;

assert_eq!(Rotation::None.reverse(), Rotation::None);
assert_eq!(Rotation::Flip.reverse(), Rotation::Flip);
assert_eq!(Clockwise.reverse(), Anticlockwise);
assert_eq!(Anticlockwise.reverse(), Clockwise);

Trait Implementations§

source§

impl Add for Rotation

§

type Output = Rotation

The resulting type after applying the + operator.
source§

fn add(self, rhs: Rotation) -> Rotation

Performs the + operation. Read more
source§

impl AddAssign for Rotation

source§

fn add_assign(&mut self, rhs: Rotation)

Performs the += operation. Read more
source§

impl Clone for Rotation

source§

fn clone(&self) -> Rotation

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Rotation

source§

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

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

impl Hash for Rotation

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 Mul<i16> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> Rotation

Performs the * operation. Read more
source§

impl Mul<i32> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Rotation

Performs the * operation. Read more
source§

impl Mul<i64> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Rotation

Performs the * operation. Read more
source§

impl Mul<i8> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> Rotation

Performs the * operation. Read more
source§

impl Mul<isize> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: isize) -> Rotation

Performs the * operation. Read more
source§

impl Mul<u16> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> Rotation

Performs the * operation. Read more
source§

impl Mul<u32> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Rotation

Performs the * operation. Read more
source§

impl Mul<u64> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u64) -> Rotation

Performs the * operation. Read more
source§

impl Mul<u8> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> Rotation

Performs the * operation. Read more
source§

impl Mul<usize> for Rotation

§

type Output = Rotation

The resulting type after applying the * operator.
source§

fn mul(self, rhs: usize) -> Rotation

Performs the * operation. Read more
source§

impl Neg for Rotation

§

type Output = Rotation

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl PartialEq for Rotation

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub for Rotation

§

type Output = Rotation

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Rotation) -> Rotation

Performs the - operation. Read more
source§

impl SubAssign for Rotation

source§

fn sub_assign(&mut self, rhs: Rotation)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a Rotation> for Rotation

source§

fn sum<I: Iterator<Item = &'a Rotation>>(iter: I) -> Rotation

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for Rotation

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Copy for Rotation

source§

impl Eq for Rotation

source§

impl StructuralEq for Rotation

source§

impl StructuralPartialEq for Rotation

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.