Struct chargrid_runtime::Coord
pub struct Coord {
pub x: i32,
pub y: i32,
}
Expand description
General purpose coordinate
Fields§
§x: i32
§y: i32
Implementations§
§impl Coord
impl Coord
pub const fn new(x: i32, y: i32) -> Coord
pub const fn from_size(size: Size) -> Result<Coord, DimensionTooLargeForCoord>
pub fn to_size(self) -> Result<Size, NegativeDimension>
pub const fn normalize(self, size: Size) -> Coord
pub const fn is_valid(self, size: Size) -> bool
pub const fn constrain(self, size: Size) -> Option<Coord>
pub const fn get(self, axis: Axis) -> i32
pub fn get_mut(&mut self, axis: Axis) -> &mut i32
pub fn with_axis<F>(self, axis: Axis, f: F) -> Coord
pub const fn set(self, axis: Axis, value: i32) -> Coord
pub fn set_in_place(&mut self, axis: Axis, value: i32)
pub const fn new_axis(this_axis: i32, other_axis: i32, axis: Axis) -> Coord
pub fn get_static<A>(self) -> i32where
A: StaticAxis,
pub fn get_static_mut<A>(&mut self) -> &mut i32where
A: StaticAxis,
pub fn with_static_axis<A, F>(self, f: F) -> Coord
pub fn set_static<A>(self, value: i32) -> Coordwhere
A: StaticAxis,
pub fn set_static_in_place<A>(&mut self, value: i32)where
A: StaticAxis,
pub fn new_static_axis<A>(this_axis: i32, other_axis: i32) -> Coordwhere
A: StaticAxis,
pub const fn set_x(self, x: i32) -> Coord
pub const fn set_y(self, y: i32) -> Coord
pub fn set_x_in_place(&mut self, x: i32)
pub fn set_y_in_place(&mut self, y: i32)
pub fn checked_add(self, rhs: Coord) -> Option<Coord>
pub fn checked_sub(self, rhs: Coord) -> Option<Coord>
pub fn checked_mul(self, rhs: i32) -> Option<Coord>
pub fn checked_div(self, rhs: i32) -> Option<Coord>
pub const fn magnitude2(self) -> u32
pub const fn distance2(self, other: Coord) -> u32
pub const fn manhattan_magnitude(self) -> u32
pub const fn manhattan_distance(self, other: Coord) -> u32
pub const fn opposite(self) -> Coord
pub const fn left90(self) -> Coord
pub const fn right90(self) -> Coord
pub const fn cardinal_left45(self) -> Coord
pub const fn cardinal_right45(self) -> Coord
pub const fn cardinal_left135(self) -> Coord
pub const fn cardinal_right135(self) -> Coord
pub const fn is_zero(self) -> bool
pub fn pairwise_max(self, other: Coord) -> Coord
pub fn pairwise_min(self, other: Coord) -> Coord
pub const fn transpose(self) -> Coord
Trait Implementations§
§impl<T> AddAssign<T> for Coord
impl<T> AddAssign<T> for Coord
§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+=
operation. Read more§impl<T> DivAssign<T> for Coord
impl<T> DivAssign<T> for Coord
§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read more§impl<T> MulAssign<T> for Coord
impl<T> MulAssign<T> for Coord
§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read more§impl Ord for Coord
impl Ord for Coord
§impl PartialOrd for Coord
impl PartialOrd for Coord
§fn partial_cmp(&self, other: &Coord) -> Option<Ordering>
fn partial_cmp(&self, other: &Coord) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more§impl<T> SubAssign<T> for Coord
impl<T> SubAssign<T> for Coord
§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-=
operation. Read moreimpl Copy for Coord
impl Eq for Coord
impl StructuralPartialEq for Coord
Auto Trait Implementations§
impl RefUnwindSafe for Coord
impl Send for Coord
impl Sync for Coord
impl Unpin for Coord
impl UnwindSafe for Coord
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more