Trait Directional

Source
pub trait Directional:
    Copy
    + Sized
    + Debug
    + 'static {
    type Flipped: Directional;
    type Reversed: Directional;

    // Required methods
    fn flipped(self) -> Self::Flipped;
    fn reversed(self) -> Self::Reversed;
    fn as_direction(self) -> Direction;

    // Provided methods
    fn is_vertical(self) -> bool { ... }
    fn is_horizontal(self) -> bool { ... }
    fn is_reversed(self) -> bool { ... }
}
Expand description

Trait over directional types

This trait has a variable implementation, Direction, and several fixed implementations, Right, Down, Left and Up.

Using a generic <D: Directional> allows compile-time substitution of direction information when parametrised with fixed implementations.

Required Associated Types§

Source

type Flipped: Directional

Direction flipped over diagonal (i.e. Down ↔ Right)

This allows compile-time selection of the flipped direction.

Source

type Reversed: Directional

Direction reversed along axis (i.e. Left ↔ Right)

This allows compile-time selection of the reversed direction.

Required Methods§

Source

fn flipped(self) -> Self::Flipped

Flip over diagonal (i.e. Down ↔ Right)

Source

fn reversed(self) -> Self::Reversed

Reverse along axis (i.e. Left ↔ Right)

Source

fn as_direction(self) -> Direction

Convert to the Direction enum

Provided Methods§

Source

fn is_vertical(self) -> bool

Up or Down

Source

fn is_horizontal(self) -> bool

Left or Right

Source

fn is_reversed(self) -> bool

Left or Up

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§