[][src]Trait gridly::location::component::Component

pub trait Component: Sized + From<isize> + Copy + Debug + Ord + Eq + Hash {
    type Converse: Component<Converse = Self>;
    type Distance: VecComponent;
    fn from_location(location: &Location) -> Self;
fn combine(self, other: Self::Converse) -> Location;
fn name() -> &'static str;
fn value(self) -> isize;
fn add(self, amount: Self::Distance) -> Self;
fn distance_from(self, origin: Self) -> Self::Distance; fn distance_to(self, target: Self) -> Self::Distance { ... }
fn transpose(self) -> Self::Converse { ... } }

A component of a Location

This trait comprises a component of a Location, which may be either a Row or a Column. It is effectively an index into a given row or column of a grid; for instance, a Row can index a column in a grid.

Associated Types

type Converse: Component<Converse = Self>

The converse component (Row to Column, or vice versa)

type Distance: VecComponent

The associated vector component (Rows or Columns)

Loading content...

Required methods

fn from_location(location: &Location) -> Self

Get this component type from a Location

fn combine(self, other: Self::Converse) -> Location

Combine this component with its converse to create a Location

fn name() -> &'static str

Return the lowercase name of this component type– "row" or "column"

fn value(self) -> isize

Get the integer value of this component

fn add(self, amount: Self::Distance) -> Self

Add a distance to this component.

fn distance_from(self, origin: Self) -> Self::Distance

Find the distance between two components, using the other component as the origin

Loading content...

Provided methods

fn distance_to(self, target: Self) -> Self::Distance

Find the distance between two components, using this component as the origin

fn transpose(self) -> Self::Converse

Convert a Row into a Column or vice versa

Loading content...

Implementors

impl Component for Column[src]

type Converse = Row

type Distance = Columns

fn distance_to(self, target: Self) -> Self::Distance[src]

fn transpose(self) -> Self::Converse[src]

impl Component for Row[src]

type Converse = Column

type Distance = Rows

fn distance_to(self, target: Self) -> Self::Distance[src]

fn transpose(self) -> Self::Converse[src]

Loading content...