Struct line_2d::Coord

source ·
pub struct Coord {
    pub x: i32,
    pub y: i32,
}
Expand description

General purpose coordinate

Fields§

§x: i32§y: i32

Implementations§

source§

impl Coord

source

pub const fn new(x: i32, y: i32) -> Coord

source

pub const fn from_size(size: Size) -> Result<Coord, DimensionTooLargeForCoord>

source

pub fn to_size(self) -> Result<Size, NegativeDimension>

source

pub const fn normalize(self, size: Size) -> Coord

source

pub const fn is_valid(self, size: Size) -> bool

source

pub const fn constrain(self, size: Size) -> Option<Coord>

source

pub const fn get(self, axis: Axis) -> i32

source

pub fn get_mut(&mut self, axis: Axis) -> &mut i32

source

pub fn with_axis<F>(self, axis: Axis, f: F) -> Coordwhere F: FnMut(i32) -> i32,

source

pub const fn set(self, axis: Axis, value: i32) -> Coord

source

pub fn set_in_place(&mut self, axis: Axis, value: i32)

source

pub const fn new_axis(this_axis: i32, other_axis: i32, axis: Axis) -> Coord

source

pub fn get_static<A>(self) -> i32where A: StaticAxis,

source

pub fn get_static_mut<A>(&mut self) -> &mut i32where A: StaticAxis,

source

pub fn with_static_axis<A, F>(self, f: F) -> Coordwhere A: StaticAxis, F: FnMut(i32) -> i32,

source

pub fn set_static<A>(self, value: i32) -> Coordwhere A: StaticAxis,

source

pub fn set_static_in_place<A>(&mut self, value: i32)where A: StaticAxis,

source

pub fn new_static_axis<A>(this_axis: i32, other_axis: i32) -> Coordwhere A: StaticAxis,

source

pub const fn set_x(self, x: i32) -> Coord

source

pub const fn set_y(self, y: i32) -> Coord

source

pub fn set_x_in_place(&mut self, x: i32)

source

pub fn set_y_in_place(&mut self, y: i32)

source

pub fn checked_add(self, rhs: Coord) -> Option<Coord>

source

pub fn checked_sub(self, rhs: Coord) -> Option<Coord>

source

pub fn checked_mul(self, rhs: i32) -> Option<Coord>

source

pub fn checked_div(self, rhs: i32) -> Option<Coord>

source

pub const fn magnitude2(self) -> u32

source

pub const fn distance2(self, other: Coord) -> u32

source

pub const fn manhattan_magnitude(self) -> u32

source

pub const fn manhattan_distance(self, other: Coord) -> u32

source

pub const fn opposite(self) -> Coord

source

pub const fn left90(self) -> Coord

source

pub const fn right90(self) -> Coord

source

pub const fn cardinal_left45(self) -> Coord

source

pub const fn cardinal_right45(self) -> Coord

source

pub const fn cardinal_left135(self) -> Coord

source

pub const fn cardinal_right135(self) -> Coord

source

pub const fn is_zero(self) -> bool

source

pub fn pairwise_max(self, other: Coord) -> Coord

source

pub fn pairwise_min(self, other: Coord) -> Coord

source

pub const fn transpose(self) -> Coord

Trait Implementations§

source§

impl<'a, 'b> Add<&'a Coord> for &'b Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, _: &'a Coord) -> <&'b Coord as Add<&'a Coord>>::Output

Performs the + operation. Read more
source§

impl<'a> Add<&'a Coord> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, _: &'a Coord) -> <Coord as Add<&'a Coord>>::Output

Performs the + operation. Read more
source§

impl<'a, 'b> Add<&'a Size> for &'b Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, size: &'a Size) -> <&'b Coord as Add<&'a Size>>::Output

Performs the + operation. Read more
source§

impl<'a> Add<&'a Size> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, size: &'a Size) -> <Coord as Add<&'a Size>>::Output

Performs the + operation. Read more
source§

impl<'a> Add<Coord> for &'a Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, _: Coord) -> <&'a Coord as Add<Coord>>::Output

Performs the + operation. Read more
source§

impl Add<Coord> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, _: Coord) -> <Coord as Add<Coord>>::Output

Performs the + operation. Read more
source§

impl<'a> Add<Size> for &'a Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, size: Size) -> <&'a Coord as Add<Size>>::Output

Performs the + operation. Read more
source§

impl Add<Size> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, size: Size) -> <Coord as Add<Size>>::Output

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for Coordwhere Coord: Add<T, Output = Coord>,

source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
source§

impl Clone for Coord

source§

fn clone(&self) -> Coord

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Coord

source§

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

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

impl Default for Coord

source§

fn default() -> Coord

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

impl<'a> Div<i32> for &'a Coord

§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> <&'a Coord as Div<i32>>::Output

Performs the / operation. Read more
source§

impl Div<i32> for Coord

§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> <Coord as Div<i32>>::Output

Performs the / operation. Read more
source§

impl<T> DivAssign<T> for Coordwhere Coord: Div<T, Output = Coord>,

source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
source§

impl From<[i32; 2]> for Coord

source§

fn from(array: [i32; 2]) -> Coord

Converts to this type from the input type.
source§

impl From<(i32, i32)> for Coord

source§

fn from(_: (i32, i32)) -> Coord

Converts to this type from the input type.
source§

impl Hash for Coord

source§

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

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

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<'a> Mul<i32> for &'a Coord

§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> <&'a Coord as Mul<i32>>::Output

Performs the * operation. Read more
source§

impl Mul<i32> for Coord

§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> <Coord as Mul<i32>>::Output

Performs the * operation. Read more
source§

impl<T> MulAssign<T> for Coordwhere Coord: Mul<T, Output = Coord>,

source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
source§

impl<'a> Neg for &'a Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn neg(self) -> <&'a Coord as Neg>::Output

Performs the unary - operation. Read more
source§

impl Neg for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn neg(self) -> <Coord as Neg>::Output

Performs the unary - operation. Read more
source§

impl Ord for Coord

source§

fn cmp(&self, other: &Coord) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Coord> for Coord

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Coord> for Coord

source§

fn partial_cmp(&self, other: &Coord) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, 'b> Sub<&'a Coord> for &'b Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, _: &'a Coord) -> <&'b Coord as Sub<&'a Coord>>::Output

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Coord> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, _: &'a Coord) -> <Coord as Sub<&'a Coord>>::Output

Performs the - operation. Read more
source§

impl<'a, 'b> Sub<&'a Size> for &'b Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, size: &'a Size) -> <&'b Coord as Sub<&'a Size>>::Output

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Size> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, size: &'a Size) -> <Coord as Sub<&'a Size>>::Output

Performs the - operation. Read more
source§

impl<'a> Sub<Coord> for &'a Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, _: Coord) -> <&'a Coord as Sub<Coord>>::Output

Performs the - operation. Read more
source§

impl Sub<Coord> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, _: Coord) -> <Coord as Sub<Coord>>::Output

Performs the - operation. Read more
source§

impl<'a> Sub<Size> for &'a Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, size: Size) -> <&'a Coord as Sub<Size>>::Output

Performs the - operation. Read more
source§

impl Sub<Size> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, size: Size) -> <Coord as Sub<Size>>::Output

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for Coordwhere Coord: Sub<T, Output = Coord>,

source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
source§

impl Copy for Coord

source§

impl Eq for Coord

source§

impl StructuralEq for Coord

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · source§

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.