pub struct Coordinate {
pub x: i32,
pub y: i32,
}Expand description
A two-dimensional point.
Fields§
§x: i32§y: i32Implementations§
Source§impl Coordinate
impl Coordinate
pub fn coordinate_in_direction( direction: &AbsoluteDirection, magnitude: usize, ) -> Self
pub fn move_in_direction( &mut self, direction: &AbsoluteDirection, magnitude: usize, )
Sourcepub fn is_above_row(&self, row: i32) -> bool
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.
Sourcepub fn is_below_row(&self, row: i32) -> bool
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
impl Add for Coordinate
Source§impl Clone for Coordinate
impl Clone for Coordinate
Source§fn clone(&self) -> Coordinate
fn clone(&self) -> Coordinate
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Coordinate
impl Debug for Coordinate
Source§impl Default for Coordinate
impl Default for Coordinate
Source§fn default() -> Coordinate
fn default() -> Coordinate
Returns the “default value” for a type. Read more
Source§impl Hash for Coordinate
impl Hash for Coordinate
Source§impl PartialEq for Coordinate
impl PartialEq for Coordinate
Source§impl Positioned for Coordinate
impl Positioned for Coordinate
fn position(&self) -> &Coordinate
fn x_coordinate(&self) -> i32
fn y_coordinate(&self) -> i32
fn manhattan_distance_to_origin(&self) -> usize
Source§fn manhattan_distance_to<C: Positioned>(&self, cord: &C) -> usizewhere
Self: Sized,
fn manhattan_distance_to<C: Positioned>(&self, cord: &C) -> usizewhere
Self: Sized,
Returns the manhattan distance to another
Positioned. Read moreSource§fn manhattan_neighbors(&self) -> Vec<Coordinate>
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>
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) -> Coordinatewhere
Self: Sized,
fn difference(&self, other: &Self) -> Coordinatewhere
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)
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.
fn on_opposite_sides_of_row(&self, cord: &Self, row: &i32) -> boolwhere
Self: Sized,
fn on_opposite_sides_of_column(&self, cord: &Self, row: &i32) -> boolwhere
Self: Sized,
Source§fn coordinate_in_direction(
&self,
direction: AbsoluteDirection,
magnitude: u32,
) -> Coordinate
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.
impl Copy for Coordinate
impl Eq for Coordinate
impl StructuralPartialEq for Coordinate
Auto Trait Implementations§
impl Freeze for Coordinate
impl RefUnwindSafe for Coordinate
impl Send for Coordinate
impl Sync for Coordinate
impl Unpin for Coordinate
impl UnwindSafe for Coordinate
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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