Struct spade::Point2

source ·
pub struct Point2<S> {
    pub x: S,
    pub y: S,
}
Expand description

A two dimensional point.

This is the basic type used for defining positions.

Fields§

§x: S

The point’s x coordinate

§y: S

The point’s y coordinate

Implementations§

source§

impl<S> Point2<S>

source

pub const fn new(x: S, y: S) -> Self

Creates a new point.

source§

impl<S: SpadeNum> Point2<S>

source

pub fn distance_2(&self, other: Self) -> S

Returns the squared distance of this point and another point.

Trait Implementations§

source§

impl<S: Clone> Clone for Point2<S>

source§

fn clone(&self) -> Point2<S>

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<S: Debug> Debug for Point2<S>

source§

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

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

impl<S: Default> Default for Point2<S>

source§

fn default() -> Point2<S>

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

impl<S: SpadeNum> From<[S; 2]> for Point2<S>

source§

fn from(source: [S; 2]) -> Self

Converts to this type from the input type.
source§

impl<S: SpadeNum> From<(S, S)> for Point2<S>

source§

fn from(source: (S, S)) -> Self

Converts to this type from the input type.
source§

impl<S: SpadeNum> From<Point2<S>> for [S; 2]

source§

fn from(point: Point2<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpadeNum> From<Point2<S>> for (S, S)

source§

fn from(point: Point2<S>) -> (S, S)

Converts to this type from the input type.
source§

impl<S: SpadeNum> HasPosition for Point2<S>

§

type Scalar = S

The number type used by this coordinate type.
source§

fn position(&self) -> Point2<S>

Returns the position of this object. Read more
source§

impl<S: Hash> Hash for Point2<S>

source§

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

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<S: PartialEq> PartialEq for Point2<S>

source§

fn eq(&self, other: &Point2<S>) -> 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<S: PartialOrd> PartialOrd for Point2<S>

source§

fn partial_cmp(&self, other: &Point2<S>) -> 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<S: Copy> Copy for Point2<S>

source§

impl<S: Eq> Eq for Point2<S>

source§

impl<S> StructuralEq for Point2<S>

source§

impl<S> StructuralPartialEq for Point2<S>

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Point2<S>
where S: RefUnwindSafe,

§

impl<S> Send for Point2<S>
where S: Send,

§

impl<S> Sync for Point2<S>
where S: Sync,

§

impl<S> Unpin for Point2<S>
where S: Unpin,

§

impl<S> UnwindSafe for Point2<S>
where S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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 T
where 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 T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

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

Performs the conversion.