Coordinate

Struct Coordinate 

Source
pub struct Coordinate {
    pub x: i32,
    pub y: i32,
}
Expand description

A two-dimensional point.

Fields§

§x: i32§y: i32

Implementations§

Source§

impl Coordinate

Source

pub fn coordinate_in_direction( direction: &AbsoluteDirection, magnitude: usize, ) -> Self

Source

pub fn move_in_direction( &mut self, direction: &AbsoluteDirection, magnitude: usize, )

Source

pub fn is_above_row(&self, row: i32) -> bool

Checks if the coordinate is above a row. If the coordinate is on the row the function returns true.

Source

pub fn is_below_row(&self, row: i32) -> bool

Checks if the coordinate is below a row. If the coordinate is on the row the function returns true.

Trait Implementations§

Source§

impl Add for Coordinate

Source§

type Output = Coordinate

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl Clone for Coordinate

Source§

fn clone(&self) -> Coordinate

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Coordinate

Source§

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

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

impl Default for Coordinate

Source§

fn default() -> Coordinate

Returns the “default value” for a type. Read more
Source§

impl Hash for Coordinate

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0§

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 PartialEq for Coordinate

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Positioned for Coordinate

Source§

fn position(&self) -> &Coordinate

Source§

fn x_coordinate(&self) -> i32

Source§

fn y_coordinate(&self) -> i32

Source§

fn manhattan_distance_to_origin(&self) -> usize

Source§

fn manhattan_distance_to<C: Positioned>(&self, cord: &C) -> usize
where Self: Sized,

Returns the manhattan distance to another Positioned. Read more
Source§

fn manhattan_neighbors(&self) -> Vec<Coordinate>

Return a vec of the immediately surrounding coordinates to the current coordinate, not considering diagonals. Read more
Source§

fn euclid_neighbors(&self) -> Vec<Coordinate>

Return a vec of the immediately surrounding coordinates to the current coordinate, including diagonals. Read more
Source§

fn difference(&self, other: &Self) -> Coordinate
where Self: Sized,

subtract the coordinates. Note that this method returns the signed difference rather than the absolute x/y distances.
Source§

fn direction_toward( &self, target: &Coordinate, ) -> (AbsoluteDirection, AbsoluteDirection)

returns the absolute directions from self to another coordinate. If the direction in an exact direction (for instance , straight north) it returns that direction twice.
Source§

fn on_opposite_sides_of_row(&self, cord: &Self, row: &i32) -> bool
where Self: Sized,

Source§

fn on_opposite_sides_of_column(&self, cord: &Self, row: &i32) -> bool
where Self: Sized,

Source§

fn coordinate_in_direction( &self, direction: AbsoluteDirection, magnitude: u32, ) -> Coordinate

Max allowed magnitude is 2^31. Numbers larger than this yield undefined behavior. If the current coordinate + magnitude is larger than 2^32, that will also trigger undefined behavior.
Source§

impl Copy for Coordinate

Source§

impl Eq for Coordinate

Source§

impl StructuralPartialEq for Coordinate

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.