Expand description
General purpose coordinate
Fields
x: i32
y: i32
Implementations
sourceimpl Coord
impl Coord
pub const fn new(x: i32, y: i32) -> Self
pub const fn from_size(size: Size) -> Result<Self, DimensionTooLargeForCoord>
pub fn to_size(self) -> Result<Size, NegativeDimension>
pub const fn normalize(self, size: Size) -> Self
pub const fn is_valid(self, size: Size) -> bool
pub const fn constrain(self, size: Size) -> Option<Self>
pub const fn get(self, axis: Axis) -> i32
pub fn get_mut(&mut self, axis: Axis) -> &mut i32
pub fn with_axis<F: FnMut(i32) -> i32>(self, axis: Axis, f: F) -> Self
pub const fn set(self, axis: Axis, value: i32) -> Self
pub fn set_in_place(&mut self, axis: Axis, value: i32)
pub const fn new_axis(this_axis: i32, other_axis: i32, axis: Axis) -> Self
pub fn get_static<A: StaticAxis>(self) -> i32
pub fn get_static_mut<A: StaticAxis>(&mut self) -> &mut i32
pub fn with_static_axis<A: StaticAxis, F: FnMut(i32) -> i32>(self, f: F) -> Self
pub fn set_static<A: StaticAxis>(self, value: i32) -> Self
pub fn set_static_in_place<A: StaticAxis>(&mut self, value: i32)
pub fn new_static_axis<A: StaticAxis>(this_axis: i32, other_axis: i32) -> Self
pub const fn set_x(self, x: i32) -> Self
pub const fn set_y(self, y: i32) -> Self
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: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: i32) -> Option<Self>
pub fn checked_div(self, rhs: i32) -> Option<Self>
pub const fn magnitude2(self) -> u32
pub const fn distance2(self, other: Self) -> u32
pub const fn manhattan_magnitude(self) -> u32
pub const fn manhattan_distance(self, other: Self) -> u32
pub const fn opposite(self) -> Self
pub const fn left90(self) -> Self
pub const fn right90(self) -> Self
pub const fn cardinal_left45(self) -> Self
pub const fn cardinal_right45(self) -> Self
pub const fn cardinal_left135(self) -> Self
pub const fn cardinal_right135(self) -> Self
pub const fn is_zero(self) -> bool
pub fn pairwise_max(self, other: Self) -> Self
pub fn pairwise_min(self, other: Self) -> Self
pub const fn transpose(self) -> Self
Trait Implementations
sourceimpl<T> AddAssign<T> for Coordwhere
Coord: Add<T, Output = Coord>,
impl<T> AddAssign<T> for Coordwhere
Coord: Add<T, Output = Coord>,
sourcefn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+=
operation. Read moresourceimpl<T> DivAssign<T> for Coordwhere
Coord: Div<T, Output = Coord>,
impl<T> DivAssign<T> for Coordwhere
Coord: Div<T, Output = Coord>,
sourcefn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moresourceimpl<T> MulAssign<T> for Coordwhere
Coord: Mul<T, Output = Coord>,
impl<T> MulAssign<T> for Coordwhere
Coord: Mul<T, Output = Coord>,
sourcefn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moresourceimpl Ord for Coord
impl Ord for Coord
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Coord> for Coord
impl PartialOrd<Coord> for Coord
sourcefn partial_cmp(&self, other: &Coord) -> Option<Ordering>
fn partial_cmp(&self, other: &Coord) -> Option<Ordering>
1.0.0 · sourcefn 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 moresourceimpl<T> SubAssign<T> for Coordwhere
Coord: Sub<T, Output = Coord>,
impl<T> SubAssign<T> for Coordwhere
Coord: Sub<T, Output = Coord>,
sourcefn 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 StructuralEq 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more