Struct gardiz::coord::Vec2

source ·
pub struct Vec2<T> {
    pub y: T,
    pub x: T,
}
Expand description

Generic 2D vector. It could be a coordinate, it could be size, anything like that.

Fields§

§y: T

Value of the Y-coordinate.

§x: T

Value of the X-coordinate.

Implementations§

source§

impl<T> Vec2<T>

source

pub fn from_axes<F>(mapper: F) -> Selfwhere F: FnMut(Axis) -> T,

Creates a vector from a function over axis to data.

source

pub fn as_ref(&self) -> Vec2<&T>

Maps coordinates to references.

source

pub fn as_mut(&mut self) -> Vec2<&mut T>

Maps coordinates to mutable references.

source

pub fn map<F, U>(self, mapper: F) -> Vec2<U>where F: FnMut(T) -> U,

Maps each coordinate to a given value and builds a new vector from the output of the mapping function.

source

pub fn map_with_axes<F, U>(self, mapper: F) -> Vec2<U>where F: FnMut(Axis, T) -> U,

Maps each coordinate to a given value in a new vector, but the mapping function gets the axis of each coordinate.

source

pub fn fold<F, U>(self, init: U, folder: F) -> Uwhere F: FnMut(T, U) -> U,

Performs a fold/reduce: i.e. accumulates the coordinates into a final result, given an initial value and an accumulator function, using first x and then y.

source

pub fn fold_rev<F, U>(self, init: U, folder: F) -> Uwhere F: FnMut(U, T) -> U,

Performs a fold/reduce: i.e. accumulates the coordinates given initial value and accumulator function, but using first y the x.

source

pub fn zip<U>(self, other: Vec2<U>) -> Vec2<(T, U)>

Zips two vectors into a vector of tuples. The result is:

zip([a,b], [c,d]) = [(a,c), (b,d)]

source

pub fn zip_with<F, U, B>(self, other: Vec2<U>, zipper: F) -> Vec2<B>where F: FnMut(T, U) -> B,

Zips two vectors using a zipper function f. The result is:

zip_with(f, [a,b], [c,d]) = [f(a,c), f(b,d)]

source

pub fn borrow<K>(&self) -> Vec2<&K>where T: Borrow<K>,

Borrows each coordinate.

source

pub fn borrow_mut<K>(&mut self) -> Vec2<&mut K>where T: BorrowMut<K>,

Borrows each coordinate as mutable references.

source§

impl<'elems, T> Vec2<&'elems T>

source

pub fn cloned(self) -> Vec2<T>where T: Clone,

Clones every coordinate.

source

pub fn copied(self) -> Vec2<T>where T: Copy,

Copies every coordinate.

source

pub fn into_borrow<K>(self) -> Vec2<&'elems K>where T: Borrow<K>,

Borrows each coordinate.

source§

impl<'elems, T> Vec2<&'elems mut T>

source

pub fn into_borrow_mut<K>(self) -> Vec2<&'elems mut K>where T: BorrowMut<K>,

Borrows each coordinate as mutable references.

source§

impl<T> Vec2<T>

source

pub fn dot<U, A>(self, other: Vec2<U>) -> A::Outputwhere T: Mul<U, Output = A>, A: Add,

Computes the dot product of the vector, i.e. x1 * x2 + y1 * y2.

Examples
use gardiz::coord::Vec2;

let left: Vec2<u16> = Vec2 { x: 5, y: 3 };
let right = Vec2 { x: 4, y: 8 };
assert_eq!(left.dot(right), 5 * 4 + 3 * 8);
source

pub fn dot_ref<'this, 'other, U, A>( &'this self, other: &'other Vec2<U> ) -> A::Outputwhere &'this T: Mul<&'other U, Output = A>, A: Add,

Computes the dot product of the vector, by reference.

source

pub fn wrapping_dot(&self, other: &Self) -> Twhere T: WrappingAdd + WrappingMul,

Computes the dot product of the vector, wrapping around overflow.

source

pub fn saturating_dot(&self, other: &Self) -> Twhere T: SaturatingAdd + SaturatingMul,

Computes the dot product of the vector, saturating when it overflows.

source

pub fn checked_dot(&self, other: &Self) -> Option<T>where T: CheckedAdd + CheckedMul,

Computes the dot product of the vector, returning None if it overflows.

source

pub fn sqr_magnitude<A>(self) -> A::Outputwhere T: Clone + Mul<Output = A>, A: Add,

Computes the square of the magnitude of the vector. The formula is: x * x + y * y.

Examples
use gardiz::coord::Vec2;

let vector: Vec2<u16> = Vec2 { x: 5, y: 3 };
assert_eq!(vector.sqr_magnitude(), 5 * 5 + 3 * 3);
source

pub fn sqr_magnitude_ref<'this, A>(&'this self) -> A::Outputwhere &'this T: Mul<Output = A>, A: Add,

Computes the square of the magnitude of the vector by reference.

source

pub fn wrapping_sqr_mag(&self) -> Twhere T: WrappingAdd + WrappingMul,

Computes the square of the magnitude of the vector, wrapping on overflow.

source

pub fn saturating_sqr_mag(&self) -> Twhere T: SaturatingMul + SaturatingAdd,

Computes the square of the magnitude of the vector, saturating on overflow.

source

pub fn checked_sqr_mag(&self) -> Option<T>where T: CheckedMul + CheckedAdd,

Computes the square of the magnitude of the vector, returning None on overflow.

source

pub fn magnitude<A>(self) -> A::Outputwhere T: Clone + Mul<Output = A>, A: Add, A::Output: Float,

Computes the magnitude of a float vector. The formula is sqrt(x*x + y*y).

source

pub fn magnitude_ref<'this, A>(&'this self) -> A::Outputwhere &'this T: Mul<&'this T, Output = A>, A: Add, A::Output: Float,

Computes the magnitude of a float vector by reference.

source

pub fn wrapping_mag(&self) -> Twhere T: WrappingAdd + WrappingMul + Float,

Computes the magnitude of a float vector wrapping around on overflow.

source

pub fn saturating_mag(&self) -> Twhere T: SaturatingAdd + SaturatingMul + Float,

Computes the magnitude of a float vector saturating on overflow.

source

pub fn checked_mag(&self) -> Option<T>where T: CheckedAdd + CheckedMul + Float,

Computes the magnitude of a float vector returning None on overflow.

source

pub fn int_magnitude<A>(self) -> A::Outputwhere T: Clone + Mul<Output = A>, A: Add, A::Output: Roots,

Computes the magnitude of the vector truncated (as an integer).

Examples
use gardiz::coord::Vec2;
use num::integer::Roots;

let vector: Vec2<u16> = Vec2 { x: 4, y: 3 };
assert_eq!(vector.int_magnitude(), 5);
source

pub fn int_magnitude_ref<'this, A>(&'this self) -> A::Outputwhere &'this T: Mul<&'this T, Output = A>, A: Add, A::Output: Roots,

Computes the magnitude of the vector truncated (as an integer), by reference.

source

pub fn wrapping_int_mag(&self) -> Twhere T: WrappingAdd + WrappingMul + Roots,

Computes the magnitude of the vector truncated (as an integer), wrapping around on overflow.

source

pub fn saturating_int_mag(&self) -> Twhere T: SaturatingAdd + SaturatingMul + Roots,

Computes the magnitude of the vector truncated (as an integer), saturating on overflow.

source

pub fn checked_int_mag(&self) -> Option<T>where T: CheckedAdd + CheckedMul + Roots,

Computes the magnitude of the vector truncated (as an integer), returning None on overflow.

source

pub fn move_one(self, direction: Direction) -> Selfwhere T: Add<Output = T> + Sub<Output = T> + One,

Moves this vector in the given direction by one.

Examples
use gardiz::coord::Vec2;
use gardiz::direc::Direction;

let vector: Vec2<u16> = Vec2 { x: 4, y: 3 };
assert_eq!(vector.move_one(Direction::Up), Vec2 { x: 4, y: 2 });
source

pub fn wrapping_move(self, direction: Direction) -> Selfwhere T: WrappingAdd + WrappingSub + One,

Moves this vector in the given direction by one, wrapping around on overflow.

source

pub fn saturating_move(self, direction: Direction) -> Selfwhere T: SaturatingAdd + SaturatingSub + One,

Moves this vector in the given direction by one, saturating on overflow.

source

pub fn checked_move(self, direction: Direction) -> Option<Self>where T: CheckedAdd + CheckedSub + One,

Moves this vector in the given direction by one, returning None on overflow.

source

pub fn move_by<U>(self, vector: DirecVector<U>) -> Selfwhere T: Add<U, Output = T> + Sub<U, Output = T>,

Moves this vector in the given direction by the given amount.

Examples
use gardiz::coord::Vec2;
use gardiz::direc::{Direction, DirecVector};

let vector: Vec2<u16> = Vec2 { x: 4, y: 3 };
let direc_vector = DirecVector { direction: Direction::Right, magnitude: 5 };
assert_eq!(vector.move_by(direc_vector), Vec2 { x: 9, y: 3 });
source

pub fn wrapping_move_by(self, vector: &DirecVector<T>) -> Selfwhere T: WrappingAdd + WrappingSub,

Moves this vector in the given direction by the given amount, wrapping around on overflow.

source

pub fn saturating_move_by(self, vector: &DirecVector<T>) -> Selfwhere T: SaturatingAdd + SaturatingSub,

Moves this vector in the given direction by the given amount, saturating on overflow.

source

pub fn checked_move_by(self, vector: &DirecVector<T>) -> Option<Self>where T: CheckedAdd + CheckedSub,

Moves this vector in the given direction by the given amount, returning None on overflow.

source

pub fn direction_to(&self, other: &Self) -> Option<Direction>where T: Ord,

Returns a “straight” direction into another point. Returns None if there is no straight direction between this point and the other point.

source

pub fn flip_y(self) -> Selfwhere T: Sub<Output = T> + Neg<Output = T> + One,

Useful for showing signed coordinates to humans, when the vector represents coordinates. Flips the Y coordinate, i.e. inverts the number line, the greatest value becomes the lesser, the lesser becomes the greatest, made for 2’s complement numbers. The formula is something like this:

flip_y([x,y]) = [x, -1 - y]

source

pub fn center_origin_at<U>(self, origin: &Vec2<T>) -> Vec2<U>where Self: ExcessToSigned<Target = Vec2<U>>, U: Sub<Output = U> + Neg<Output = U> + One,

Useful for showing unsigned coordinates to humans, when the vector represents coordinates. First, it reinterprets the unsigned coordinats as “excess of N” numbers, such that N is the new origin, then it flips the Y coordinate. The formula is something like this:

center_origin_at([x,y], N) = [x - N, -1 - (y - N)]

Examples
use gardiz::coord::Vec2;

let vector: Vec2<u8> = Vec2 { x: 105, y: 97 };
let centered: Vec2<i8> = Vec2 { x: 5, y: 102 };
assert_eq!(
    vector.center_origin_at(&Vec2 { x: 100, y: 200 }),
    centered
);
source

pub fn center_origin<U>(self) -> Vec2<U>where Self: ExcessToSigned<Target = Vec2<U>> + HalfExcess, U: Sub<Output = U> + Neg<Output = U> + One,

Useful for showing unsigned coordinates to humans, when the vector represents coordinates. Like center_origin_at, but it uses half of the unsigned type’s maximum value as the excess (with truncated division). First of all, half the maximum value becomes the new zero, then Y-axis is flipped. The formula is something like this:

center_origin_at([x,y]) = [x - 1000...0000, -1 - (y - 1000...0000)]

Examples
use gardiz::coord::Vec2;

let vector: Vec2<u8> = Vec2 { x: 127, y: 130 };
let centered: Vec2<i8> = Vec2 { x: -1, y: -3 };
assert_eq!(vector.center_origin(), centered);
source§

impl<T> Vec2<Option<T>>

source

pub fn transpose(self) -> Option<Vec2<T>>

Transpose a vector of options into an option of vectors: a single coordinate with None makes the return value be None, while both being Some make it be Some.

source§

impl<T, E> Vec2<Result<T, E>>

source

pub fn transpose_err_x(self) -> Result<Vec2<T>, E>

Transpose a vector of Result into a Result of vectors: a single coordinate with Err makes the return value be Err, while both being Ok make it be Ok. An error on x gets priority over an error on y.

source

pub fn transpose_err_y(self) -> Result<Vec2<T>, E>

Transpose a vector of Result into a Result of vectors: a single coordinate with Err makes the return value be Err, while both being Ok make it be Ok. An error on y gets priority over an error on x.

Trait Implementations§

source§

impl<'this, 'other, T, U> Add<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Add<&'other U>,

§

type Output = Vec2<<&'this T as Add<&'other U>>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: &'other Vec2<U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'other, T, U> Add<&'other Vec2<U>> for Vec2<T>where T: Add<&'other U>,

§

type Output = Vec2<<T as Add<&'other U>>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: &'other Vec2<U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'this, T, U> Add<Vec2<U>> for &'this Vec2<T>where &'this T: Add<U>,

§

type Output = Vec2<<&'this T as Add<U>>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: Vec2<U>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, U> Add<Vec2<U>> for Vec2<T>where T: Add<U>,

§

type Output = Vec2<<T as Add<U>>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: Vec2<U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'param, T, U> AddAssign<&'param Vec2<U>> for Vec2<T>where T: AddAssign<&'param U>,

source§

fn add_assign(&mut self, other: &'param Vec2<U>)

Performs the += operation. Read more
source§

impl<T, U> AddAssign<Vec2<U>> for Vec2<T>where T: AddAssign<U>,

source§

fn add_assign(&mut self, other: Vec2<U>)

Performs the += operation. Read more
source§

impl<T> Bounded for Vec2<T>where T: Bounded,

source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
source§

fn max_value() -> Self

Returns the largest finite number this type can represent
source§

impl<T> CastSigned for Vec2<T>where T: CastSigned,

§

type Target = Vec2<<T as CastSigned>::Target>

Type of the target signed version.
source§

fn cast_signed(&self) -> Self::Target

Bit-casts the given (self) unsigned number into a signed version.
source§

impl<T> CastUnsigned for Vec2<T>where T: CastUnsigned,

§

type Target = Vec2<<T as CastUnsigned>::Target>

Type of the target unsigned version.
source§

fn cast_unsigned(&self) -> Self::Target

Bit-casts the given (self) signed number into an unsigned version.
source§

impl<T> CheckedAdd for Vec2<T>where T: CheckedAdd,

source§

fn checked_add(&self, other: &Self) -> Option<Self>

Adds two numbers, checking for overflow. If overflow happens, None is returned.
source§

impl<T> CheckedDiv for Vec2<T>where T: CheckedDiv,

source§

fn checked_div(&self, other: &Self) -> Option<Self>

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.
source§

impl<T> CheckedMul for Vec2<T>where T: CheckedMul,

source§

fn checked_mul(&self, other: &Self) -> Option<Self>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
source§

impl<T> CheckedNeg for Vec2<T>where T: CheckedNeg,

source§

fn checked_neg(&self) -> Option<Self>

Negates a number, returning None for results that can’t be represented, like signed MIN values that can’t be positive, or non-zero unsigned values that can’t be negative. Read more
source§

impl<T> CheckedRem for Vec2<T>where T: CheckedRem,

source§

fn checked_rem(&self, other: &Self) -> Option<Self>

Finds the remainder of dividing two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned. Read more
source§

impl<T> CheckedSub for Vec2<T>where T: CheckedSub,

source§

fn checked_sub(&self, other: &Self) -> Option<Self>

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
source§

impl<T: Clone> Clone for Vec2<T>

source§

fn clone(&self) -> Vec2<T>

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<T: Debug> Debug for Vec2<T>

source§

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

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

impl<T: Default> Default for Vec2<T>

source§

fn default() -> Vec2<T>

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

impl<'de, T> Deserialize<'de> for Vec2<T>where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Display for Vec2<T>where T: Display,

source§

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

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

impl<'this, 'other, T, U> Div<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Div<&'other U>,

§

type Output = Vec2<<&'this T as Div<&'other U>>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: &'other Vec2<U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'other, T, U> Div<&'other Vec2<U>> for Vec2<T>where T: Div<&'other U>,

§

type Output = Vec2<<T as Div<&'other U>>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: &'other Vec2<U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'this, T, U> Div<Vec2<U>> for &'this Vec2<T>where &'this T: Div<U>,

§

type Output = Vec2<<&'this T as Div<U>>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: Vec2<U>) -> Self::Output

Performs the / operation. Read more
source§

impl<T, U> Div<Vec2<U>> for Vec2<T>where T: Div<U>,

§

type Output = Vec2<<T as Div<U>>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: Vec2<U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'param, T, U> DivAssign<&'param Vec2<U>> for Vec2<T>where T: DivAssign<&'param U>,

source§

fn div_assign(&mut self, other: &'param Vec2<U>)

Performs the /= operation. Read more
source§

impl<T, U> DivAssign<Vec2<U>> for Vec2<T>where T: DivAssign<U>,

source§

fn div_assign(&mut self, other: Vec2<U>)

Performs the /= operation. Read more
source§

impl<T> Extend<Vec2<T>> for Set<T>where T: Ord + Clone,

source§

fn extend<I>(&mut self, iter: I)where I: IntoIterator<Item = Vec2<T>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'this, T> From<&'this Vec2<T>> for Vec2<&'this T>

source§

fn from(input: &'this Vec2<T>) -> Self

Converts to this type from the input type.
source§

impl<'this, T> From<&'this mut Vec2<T>> for Vec2<&'this mut T>

source§

fn from(input: &'this mut Vec2<T>) -> Self

Converts to this type from the input type.
source§

impl<T> FromIterator<Vec2<T>> for Set<T>where T: Ord + Clone,

source§

fn from_iter<I>(iter: I) -> Selfwhere I: IntoIterator<Item = Vec2<T>>,

Creates a value from an iterator. Read more
source§

impl<T: Hash> Hash for Vec2<T>

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<T> Index<Axis> for Vec2<T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, axis: Axis) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<Axis> for Vec2<T>

source§

fn index_mut(&mut self, axis: Axis) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'this, 'other, T, U> Mul<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Mul<&'other U>,

§

type Output = Vec2<<&'this T as Mul<&'other U>>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'other Vec2<U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'other, T, U> Mul<&'other Vec2<U>> for Vec2<T>where T: Mul<&'other U>,

§

type Output = Vec2<<T as Mul<&'other U>>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'other Vec2<U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'this, T, U> Mul<Vec2<U>> for &'this Vec2<T>where &'this T: Mul<U>,

§

type Output = Vec2<<&'this T as Mul<U>>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vec2<U>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, U> Mul<Vec2<U>> for Vec2<T>where T: Mul<U>,

§

type Output = Vec2<<T as Mul<U>>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vec2<U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'param, T, U> MulAssign<&'param Vec2<U>> for Vec2<T>where T: MulAssign<&'param U>,

source§

fn mul_assign(&mut self, other: &'param Vec2<U>)

Performs the *= operation. Read more
source§

impl<T, U> MulAssign<Vec2<U>> for Vec2<T>where T: MulAssign<U>,

source§

fn mul_assign(&mut self, other: Vec2<U>)

Performs the *= operation. Read more
source§

impl<'this, T> Neg for &'this Vec2<T>where &'this T: Neg,

§

type Output = Vec2<<&'this T as Neg>::Output>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T> Neg for Vec2<T>where T: Neg,

§

type Output = Vec2<<T as Neg>::Output>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T> Not for Vec2<T>

§

type Output = Vec2<T>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<T> Num for Vec2<T>where T: Num,

§

type FromStrRadixErr = FromStrRadixErr<<T as Num>::FromStrRadixErr>

source§

fn from_str_radix( input: &str, radix: u32 ) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
source§

impl<T> One for Vec2<T>where T: One,

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl<T: Ord> Ord for Vec2<T>

source§

fn cmp(&self, other: &Vec2<T>) -> 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<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>

source§

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

source§

fn partial_cmp(&self, other: &Vec2<T>) -> 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<'this, 'other, T, U> Pow<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Pow<&'other U>,

§

type Output = Vec2<<&'this T as Pow<&'other U>>::Output>

The result after applying the operator.
source§

fn pow(self, other: &'other Vec2<U>) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<'other, T, U> Pow<&'other Vec2<U>> for Vec2<T>where T: Pow<&'other U>,

§

type Output = Vec2<<T as Pow<&'other U>>::Output>

The result after applying the operator.
source§

fn pow(self, other: &'other Vec2<U>) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<'this, T, U> Pow<Vec2<U>> for &'this Vec2<T>where &'this T: Pow<U>,

§

type Output = Vec2<<&'this T as Pow<U>>::Output>

The result after applying the operator.
source§

fn pow(self, other: Vec2<U>) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<T, U> Pow<Vec2<U>> for Vec2<T>where T: Pow<U>,

§

type Output = Vec2<<T as Pow<U>>::Output>

The result after applying the operator.
source§

fn pow(self, other: Vec2<U>) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<'this, 'other, T, U> Rem<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Rem<&'other U>,

§

type Output = Vec2<<&'this T as Rem<&'other U>>::Output>

The resulting type after applying the % operator.
source§

fn rem(self, other: &'other Vec2<U>) -> Self::Output

Performs the % operation. Read more
source§

impl<'other, T, U> Rem<&'other Vec2<U>> for Vec2<T>where T: Rem<&'other U>,

§

type Output = Vec2<<T as Rem<&'other U>>::Output>

The resulting type after applying the % operator.
source§

fn rem(self, other: &'other Vec2<U>) -> Self::Output

Performs the % operation. Read more
source§

impl<'this, T, U> Rem<Vec2<U>> for &'this Vec2<T>where &'this T: Rem<U>,

§

type Output = Vec2<<&'this T as Rem<U>>::Output>

The resulting type after applying the % operator.
source§

fn rem(self, other: Vec2<U>) -> Self::Output

Performs the % operation. Read more
source§

impl<T, U> Rem<Vec2<U>> for Vec2<T>where T: Rem<U>,

§

type Output = Vec2<<T as Rem<U>>::Output>

The resulting type after applying the % operator.
source§

fn rem(self, other: Vec2<U>) -> Self::Output

Performs the % operation. Read more
source§

impl<'param, T, U> RemAssign<&'param Vec2<U>> for Vec2<T>where T: RemAssign<&'param U>,

source§

fn rem_assign(&mut self, other: &'param Vec2<U>)

Performs the %= operation. Read more
source§

impl<T, U> RemAssign<Vec2<U>> for Vec2<T>where T: RemAssign<U>,

source§

fn rem_assign(&mut self, other: Vec2<U>)

Performs the %= operation. Read more
source§

impl<T> SaturatingAdd for Vec2<T>where T: SaturatingAdd,

source§

fn saturating_add(&self, other: &Self) -> Self

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.
source§

impl<T> SaturatingMul for Vec2<T>where T: SaturatingMul,

source§

fn saturating_mul(&self, other: &Self) -> Self

Saturating multiplication. Computes self * other, saturating at the relevant high or low boundary of the type.
source§

impl<T> SaturatingSub for Vec2<T>where T: SaturatingSub,

source§

fn saturating_sub(&self, other: &Self) -> Self

Saturating subtraction. Computes self - other, saturating at the relevant high or low boundary of the type.
source§

impl<T> Serialize for Vec2<T>where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Signed for Vec2<T>where T: Signed,

source§

fn abs(&self) -> Self

Computes the absolute value. Read more
source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
source§

impl<'this, 'other, T, U> Sub<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Sub<&'other U>,

§

type Output = Vec2<<&'this T as Sub<&'other U>>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'other Vec2<U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'other, T, U> Sub<&'other Vec2<U>> for Vec2<T>where T: Sub<&'other U>,

§

type Output = Vec2<<T as Sub<&'other U>>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'other Vec2<U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'this, T, U> Sub<Vec2<U>> for &'this Vec2<T>where &'this T: Sub<U>,

§

type Output = Vec2<<&'this T as Sub<U>>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vec2<U>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, U> Sub<Vec2<U>> for Vec2<T>where T: Sub<U>,

§

type Output = Vec2<<T as Sub<U>>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vec2<U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'param, T, U> SubAssign<&'param Vec2<U>> for Vec2<T>where T: SubAssign<&'param U>,

source§

fn sub_assign(&mut self, other: &'param Vec2<U>)

Performs the -= operation. Read more
source§

impl<T, U> SubAssign<Vec2<U>> for Vec2<T>where T: SubAssign<U>,

source§

fn sub_assign(&mut self, other: Vec2<U>)

Performs the -= operation. Read more
source§

impl<T> WrappingAdd for Vec2<T>where T: WrappingAdd,

source§

fn wrapping_add(&self, other: &Self) -> Self

Wrapping (modular) addition. Computes self + other, wrapping around at the boundary of the type.
source§

impl<T> WrappingMul for Vec2<T>where T: WrappingMul,

source§

fn wrapping_mul(&self, other: &Self) -> Self

Wrapping (modular) multiplication. Computes self * other, wrapping around at the boundary of the type.
source§

impl<T> WrappingNeg for Vec2<T>where T: WrappingNeg,

source§

fn wrapping_neg(&self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type. Read more
source§

impl<T> WrappingSub for Vec2<T>where T: WrappingSub,

source§

fn wrapping_sub(&self, other: &Self) -> Self

Wrapping (modular) subtraction. Computes self - other, wrapping around at the boundary of the type.
source§

impl<T> Zero for Vec2<T>where T: Zero,

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T: Copy> Copy for Vec2<T>

source§

impl<T: Eq> Eq for Vec2<T>

source§

impl<T> StructuralEq for Vec2<T>

source§

impl<T> StructuralPartialEq for Vec2<T>

source§

impl<T> Unsigned for Vec2<T>where T: Unsigned,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Vec2<T>where T: RefUnwindSafe,

§

impl<T> Send for Vec2<T>where T: Send,

§

impl<T> Sync for Vec2<T>where T: Sync,

§

impl<T> Unpin for Vec2<T>where T: Unpin,

§

impl<T> UnwindSafe for Vec2<T>where T: UnwindSafe,

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<A> Distance<A> for Awhere A: Ord + Sub<A>,

§

type Output = <A as Sub<A>>::Output

Output number type.
source§

fn distance(self, other: A) -> <A as Distance<A>>::Output

Computes the absolute (without sign) distance between the given two numbers.
source§

impl<N> ExcessToSigned for Nwhere N: CastSigned + WrappingSub,

source§

fn excess_to_signed(&self, excess: &N) -> <N as CastSigned>::Target

Performs a conversion from an “excess of N” number to a 2’s complement number. The input is actually unsigned.
source§

fn half_exc_to_signed(&self) -> Self::Targetwhere Self: HalfExcess,

Performs a conversion from an “excess of N” number to a 2’s complement number, where N is half the maximum value of the unsigned input number.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<N> HalfExcess for Nwhere N: Unsigned + Bounded,

source§

fn half_excess() -> N

Gets the “excess” that is the half of the maximum value of an unsigned type.
source§

impl<T, U> Into<U> for Twhere 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> LowerBounded for Twhere T: Bounded,

source§

fn min_value() -> T

Returns the smallest finite number this type can represent
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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
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.
source§

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

Performs the conversion.
source§

impl<T> UpperBounded for Twhere T: Bounded,

source§

fn max_value() -> T

Returns the largest finite number this type can represent
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> NumAssign for Twhere T: Num + NumAssignOps<T>,

source§

impl<T, Rhs> NumAssignOps<Rhs> for Twhere T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T> NumAssignRef for Twhere T: NumAssign + for<'r> NumAssignOps<&'r T>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for Twhere T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T> NumRef for Twhere T: Num + for<'r> NumOps<&'r T, T>,

source§

impl<T, Base> RefNum<Base> for Twhere T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,