[][src]Struct gridly::location::Location

pub struct Location {
    pub row: Row,
    pub column: Column,
}

A location on a grid

A location is the primary indexing type for a Grid, and represents a single cell on that grid. It is comprised of a Row and a Column. By convention, increasing rows count downward and increasing columns count rightward.

Locations support arithmetic operations with Vectors.

Fields

row: Rowcolumn: Column

Methods

impl Location[src]

pub fn new(row: impl Into<Row>, column: impl Into<Column>) -> Self[src]

pub fn zero() -> Self[src]

pub fn get_component<T: Component>(&self) -> T[src]

Get either the row or column of a location

pub fn above(&self, distance: impl Into<Rows>) -> Location[src]

Return the location that is distance above this one

pub fn below(&self, distance: impl Into<Rows>) -> Location[src]

Return the location that is distance below this one

pub fn left(&self, distance: impl Into<Columns>) -> Location[src]

Return the location that is distance to the left of this one

pub fn right(&self, distance: impl Into<Columns>) -> Location[src]

Return the location that is distance to the right of this one

pub fn relative(&self, direction: Direction, distance: isize) -> Location[src]

Return the location that is distance away in the given direction

pub fn step(&self, direction: Direction) -> Location[src]

Return the location that is 1 away in the given direction

pub fn transpose(&self) -> Location[src]

Swap the row and colimn of this Location

pub fn order_by<Major: Component>(self) -> OrderedLocation<Major>[src]

pub fn row_ordered(self) -> RowOrderedLocation[src]

pub fn column_ordered(self) -> ColumnOrderedLocation[src]

Trait Implementations

impl Copy for Location[src]

impl PartialEq<Location> for Location[src]

impl Eq for Location[src]

impl<M: Component> AsMut<Location> for OrderedLocation<M>[src]

impl Clone for Location[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Location[src]

impl<R: Into<Row>, C: Into<Column>> From<(R, C)> for Location[src]

impl<M: Component> From<OrderedLocation<M>> for Location[src]

impl<M: Component> From<Location> for OrderedLocation<M>[src]

impl<M: Component> AsRef<Location> for OrderedLocation<M>[src]

impl Hash for Location[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Into<Vector>> Add<T> for Location[src]

type Output = Location

The resulting type after applying the + operator.

impl<T: Into<Vector>> Sub<T> for Location[src]

type Output = Location

The resulting type after applying the - operator.

impl Sub<Location> for Location[src]

type Output = Vector

The resulting type after applying the - operator.

impl<T: Into<Vector>> AddAssign<T> for Location[src]

impl<T: Into<Vector>> SubAssign<T> for Location[src]

impl Debug for Location[src]

Auto Trait Implementations

impl Send for Location

impl Sync for Location

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.