[][src]Enum gridly::rotation::Rotation

pub enum Rotation {
    None,
    Clockwise,
    Flip,
    Anticlockwise,
}

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

No rotation (0°)

Clockwise

Rotate 90° clockwise

Flip

Rotate 180°

Anticlockwise

Rotate 90° anticlockwise

Implementations

impl Rotation[src]

#[must_use]pub fn is_turn(self) -> bool[src]

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());

#[must_use]pub fn reverse(self) -> Self[src]

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

impl Add<Rotation> for Rotation[src]

type Output = Rotation

The resulting type after applying the + operator.

impl AddAssign<Rotation> for Rotation[src]

impl Clone for Rotation[src]

impl Copy for Rotation[src]

impl Debug for Rotation[src]

impl Eq for Rotation[src]

impl Hash for Rotation[src]

impl Mul<i16> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<i32> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<i64> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<i8> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<isize> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<u16> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<u32> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<u64> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<u8> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Mul<usize> for Rotation[src]

type Output = Rotation

The resulting type after applying the * operator.

impl Neg for Rotation[src]

type Output = Rotation

The resulting type after applying the - operator.

impl PartialEq<Rotation> for Rotation[src]

impl StructuralEq for Rotation[src]

impl StructuralPartialEq for Rotation[src]

impl Sub<Rotation> for Rotation[src]

type Output = Rotation

The resulting type after applying the - operator.

impl SubAssign<Rotation> for Rotation[src]

impl<'a> Sum<&'a Rotation> for Rotation[src]

impl Sum<Rotation> for Rotation[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.