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>
impl<T> Vec2<T>
sourcepub fn from_axes<F>(mapper: F) -> Selfwhere
F: FnMut(Axis) -> T,
pub fn from_axes<F>(mapper: F) -> Selfwhere F: FnMut(Axis) -> T,
Creates a vector from a function over axis to data.
sourcepub fn map<F, U>(self, mapper: F) -> Vec2<U>where
F: FnMut(T) -> U,
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.
sourcepub fn map_with_axes<F, U>(self, mapper: F) -> Vec2<U>where
F: FnMut(Axis, T) -> U,
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.
sourcepub fn fold<F, U>(self, init: U, folder: F) -> Uwhere
F: FnMut(T, U) -> U,
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
.
sourcepub fn fold_rev<F, U>(self, init: U, folder: F) -> Uwhere
F: FnMut(U, T) -> U,
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
.
sourcepub fn zip<U>(self, other: Vec2<U>) -> Vec2<(T, U)>
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)]
sourcepub fn zip_with<F, U, B>(self, other: Vec2<U>, zipper: F) -> Vec2<B>where
F: FnMut(T, U) -> B,
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)]
sourcepub fn borrow_mut<K>(&mut self) -> Vec2<&mut K>where
T: BorrowMut<K>,
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 mut T>
impl<'elems, T> Vec2<&'elems mut T>
sourcepub fn into_borrow_mut<K>(self) -> Vec2<&'elems mut K>where
T: BorrowMut<K>,
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>
impl<T> Vec2<T>
sourcepub fn dot<U, A>(self, other: Vec2<U>) -> A::Outputwhere
T: Mul<U, Output = A>,
A: Add,
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);
sourcepub fn dot_ref<'this, 'other, U, A>(
&'this self,
other: &'other Vec2<U>
) -> A::Outputwhere
&'this T: Mul<&'other U, Output = A>,
A: Add,
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.
sourcepub fn wrapping_dot(&self, other: &Self) -> Twhere
T: WrappingAdd + WrappingMul,
pub fn wrapping_dot(&self, other: &Self) -> Twhere T: WrappingAdd + WrappingMul,
Computes the dot product of the vector, wrapping around overflow.
sourcepub fn saturating_dot(&self, other: &Self) -> Twhere
T: SaturatingAdd + SaturatingMul,
pub fn saturating_dot(&self, other: &Self) -> Twhere T: SaturatingAdd + SaturatingMul,
Computes the dot product of the vector, saturating when it overflows.
sourcepub fn checked_dot(&self, other: &Self) -> Option<T>where
T: CheckedAdd + CheckedMul,
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.
sourcepub fn sqr_magnitude<A>(self) -> A::Outputwhere
T: Clone + Mul<Output = A>,
A: Add,
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);
sourcepub fn sqr_magnitude_ref<'this, A>(&'this self) -> A::Outputwhere
&'this T: Mul<Output = A>,
A: Add,
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.
sourcepub fn wrapping_sqr_mag(&self) -> Twhere
T: WrappingAdd + WrappingMul,
pub fn wrapping_sqr_mag(&self) -> Twhere T: WrappingAdd + WrappingMul,
Computes the square of the magnitude of the vector, wrapping on overflow.
sourcepub fn saturating_sqr_mag(&self) -> Twhere
T: SaturatingMul + SaturatingAdd,
pub fn saturating_sqr_mag(&self) -> Twhere T: SaturatingMul + SaturatingAdd,
Computes the square of the magnitude of the vector, saturating on overflow.
sourcepub fn checked_sqr_mag(&self) -> Option<T>where
T: CheckedMul + CheckedAdd,
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.
sourcepub fn magnitude<A>(self) -> A::Outputwhere
T: Clone + Mul<Output = A>,
A: Add,
A::Output: Float,
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)
.
sourcepub fn magnitude_ref<'this, A>(&'this self) -> A::Outputwhere
&'this T: Mul<&'this T, Output = A>,
A: Add,
A::Output: Float,
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.
sourcepub fn wrapping_mag(&self) -> Twhere
T: WrappingAdd + WrappingMul + Float,
pub fn wrapping_mag(&self) -> Twhere T: WrappingAdd + WrappingMul + Float,
Computes the magnitude of a float vector wrapping around on overflow.
sourcepub fn saturating_mag(&self) -> Twhere
T: SaturatingAdd + SaturatingMul + Float,
pub fn saturating_mag(&self) -> Twhere T: SaturatingAdd + SaturatingMul + Float,
Computes the magnitude of a float vector saturating on overflow.
sourcepub fn checked_mag(&self) -> Option<T>where
T: CheckedAdd + CheckedMul + Float,
pub fn checked_mag(&self) -> Option<T>where T: CheckedAdd + CheckedMul + Float,
Computes the magnitude of a float vector returning None
on overflow.
sourcepub fn int_magnitude<A>(self) -> A::Outputwhere
T: Clone + Mul<Output = A>,
A: Add,
A::Output: Roots,
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);
sourcepub fn int_magnitude_ref<'this, A>(&'this self) -> A::Outputwhere
&'this T: Mul<&'this T, Output = A>,
A: Add,
A::Output: Roots,
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.
sourcepub fn wrapping_int_mag(&self) -> Twhere
T: WrappingAdd + WrappingMul + Roots,
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.
sourcepub fn saturating_int_mag(&self) -> Twhere
T: SaturatingAdd + SaturatingMul + Roots,
pub fn saturating_int_mag(&self) -> Twhere T: SaturatingAdd + SaturatingMul + Roots,
Computes the magnitude of the vector truncated (as an integer), saturating on overflow.
sourcepub fn checked_int_mag(&self) -> Option<T>where
T: CheckedAdd + CheckedMul + Roots,
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.
sourcepub fn move_one(self, direction: Direction) -> Selfwhere
T: Add<Output = T> + Sub<Output = T> + One,
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 });
sourcepub fn wrapping_move(self, direction: Direction) -> Selfwhere
T: WrappingAdd + WrappingSub + One,
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.
sourcepub fn saturating_move(self, direction: Direction) -> Selfwhere
T: SaturatingAdd + SaturatingSub + One,
pub fn saturating_move(self, direction: Direction) -> Selfwhere T: SaturatingAdd + SaturatingSub + One,
Moves this vector in the given direction by one, saturating on overflow.
sourcepub fn checked_move(self, direction: Direction) -> Option<Self>where
T: CheckedAdd + CheckedSub + One,
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.
sourcepub fn move_by<U>(self, vector: DirecVector<U>) -> Selfwhere
T: Add<U, Output = T> + Sub<U, Output = T>,
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 });
sourcepub fn wrapping_move_by(self, vector: &DirecVector<T>) -> Selfwhere
T: WrappingAdd + WrappingSub,
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.
sourcepub fn saturating_move_by(self, vector: &DirecVector<T>) -> Selfwhere
T: SaturatingAdd + SaturatingSub,
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.
sourcepub fn checked_move_by(self, vector: &DirecVector<T>) -> Option<Self>where
T: CheckedAdd + CheckedSub,
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.
sourcepub fn direction_to(&self, other: &Self) -> Option<Direction>where
T: Ord,
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.
sourcepub fn flip_y(self) -> Selfwhere
T: Sub<Output = T> + Neg<Output = T> + One,
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]
sourcepub 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,
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
);
sourcepub fn center_origin<U>(self) -> Vec2<U>where
Self: ExcessToSigned<Target = Vec2<U>> + HalfExcess,
U: Sub<Output = U> + Neg<Output = U> + One,
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, E> Vec2<Result<T, E>>
impl<T, E> Vec2<Result<T, E>>
sourcepub fn transpose_err_x(self) -> Result<Vec2<T>, E>
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
.
sourcepub fn transpose_err_y(self) -> Result<Vec2<T>, E>
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>,
impl<'this, 'other, T, U> Add<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Add<&'other U>,
source§impl<'param, T, U> AddAssign<&'param Vec2<U>> for Vec2<T>where
T: AddAssign<&'param U>,
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>)
fn add_assign(&mut self, other: &'param Vec2<U>)
+=
operation. Read moresource§impl<T, U> AddAssign<Vec2<U>> for Vec2<T>where
T: AddAssign<U>,
impl<T, U> AddAssign<Vec2<U>> for Vec2<T>where T: AddAssign<U>,
source§fn add_assign(&mut self, other: Vec2<U>)
fn add_assign(&mut self, other: Vec2<U>)
+=
operation. Read moresource§impl<T> CastSigned for Vec2<T>where
T: CastSigned,
impl<T> CastSigned for Vec2<T>where T: CastSigned,
§type Target = Vec2<<T as CastSigned>::Target>
type Target = Vec2<<T as CastSigned>::Target>
source§fn cast_signed(&self) -> Self::Target
fn cast_signed(&self) -> Self::Target
self
) unsigned number into a signed version.source§impl<T> CastUnsigned for Vec2<T>where
T: CastUnsigned,
impl<T> CastUnsigned for Vec2<T>where T: CastUnsigned,
§type Target = Vec2<<T as CastUnsigned>::Target>
type Target = Vec2<<T as CastUnsigned>::Target>
source§fn cast_unsigned(&self) -> Self::Target
fn cast_unsigned(&self) -> Self::Target
self
) signed number into an unsigned version.source§impl<T> CheckedAdd for Vec2<T>where
T: CheckedAdd,
impl<T> CheckedAdd for Vec2<T>where T: CheckedAdd,
source§fn checked_add(&self, other: &Self) -> Option<Self>
fn checked_add(&self, other: &Self) -> Option<Self>
None
is
returned.source§impl<T> CheckedDiv for Vec2<T>where
T: CheckedDiv,
impl<T> CheckedDiv for Vec2<T>where T: CheckedDiv,
source§fn checked_div(&self, other: &Self) -> Option<Self>
fn checked_div(&self, other: &Self) -> Option<Self>
None
is returned.source§impl<T> CheckedMul for Vec2<T>where
T: CheckedMul,
impl<T> CheckedMul for Vec2<T>where T: CheckedMul,
source§fn checked_mul(&self, other: &Self) -> Option<Self>
fn checked_mul(&self, other: &Self) -> Option<Self>
None
is returned.source§impl<T> CheckedNeg for Vec2<T>where
T: CheckedNeg,
impl<T> CheckedNeg for Vec2<T>where T: CheckedNeg,
source§fn checked_neg(&self) -> Option<Self>
fn checked_neg(&self) -> Option<Self>
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 moresource§impl<T> CheckedRem for Vec2<T>where
T: CheckedRem,
impl<T> CheckedRem for Vec2<T>where T: CheckedRem,
source§impl<T> CheckedSub for Vec2<T>where
T: CheckedSub,
impl<T> CheckedSub for Vec2<T>where T: CheckedSub,
source§fn checked_sub(&self, other: &Self) -> Option<Self>
fn checked_sub(&self, other: &Self) -> Option<Self>
None
is returned.source§impl<'de, T> Deserialize<'de> for Vec2<T>where
T: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<'this, 'other, T, U> Div<&'other Vec2<U>> for &'this Vec2<T>where
&'this T: Div<&'other U>,
impl<'this, 'other, T, U> Div<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Div<&'other U>,
source§impl<'param, T, U> DivAssign<&'param Vec2<U>> for Vec2<T>where
T: DivAssign<&'param U>,
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>)
fn div_assign(&mut self, other: &'param Vec2<U>)
/=
operation. Read moresource§impl<T, U> DivAssign<Vec2<U>> for Vec2<T>where
T: DivAssign<U>,
impl<T, U> DivAssign<Vec2<U>> for Vec2<T>where T: DivAssign<U>,
source§fn div_assign(&mut self, other: Vec2<U>)
fn div_assign(&mut self, other: Vec2<U>)
/=
operation. Read moresource§impl<T> Extend<Vec2<T>> for Set<T>where
T: Ord + Clone,
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>>,
fn extend<I>(&mut self, iter: I)where I: IntoIterator<Item = Vec2<T>>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<'this, 'other, T, U> Mul<&'other Vec2<U>> for &'this Vec2<T>where
&'this T: Mul<&'other U>,
impl<'this, 'other, T, U> Mul<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Mul<&'other U>,
source§impl<'param, T, U> MulAssign<&'param Vec2<U>> for Vec2<T>where
T: MulAssign<&'param U>,
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>)
fn mul_assign(&mut self, other: &'param Vec2<U>)
*=
operation. Read moresource§impl<T, U> MulAssign<Vec2<U>> for Vec2<T>where
T: MulAssign<U>,
impl<T, U> MulAssign<Vec2<U>> for Vec2<T>where T: MulAssign<U>,
source§fn mul_assign(&mut self, other: Vec2<U>)
fn mul_assign(&mut self, other: Vec2<U>)
*=
operation. Read moresource§impl<T> Num for Vec2<T>where
T: Num,
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>
fn from_str_radix( input: &str, radix: u32 ) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl<T: Ord> Ord for Vec2<T>
impl<T: Ord> Ord for Vec2<T>
source§impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>
impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>
source§impl<T: PartialOrd> PartialOrd<Vec2<T>> for Vec2<T>
impl<T: PartialOrd> PartialOrd<Vec2<T>> for Vec2<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'this, 'other, T, U> Pow<&'other Vec2<U>> for &'this Vec2<T>where
&'this T: Pow<&'other U>,
impl<'this, 'other, T, U> Pow<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Pow<&'other U>,
source§impl<'this, 'other, T, U> Rem<&'other Vec2<U>> for &'this Vec2<T>where
&'this T: Rem<&'other U>,
impl<'this, 'other, T, U> Rem<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Rem<&'other U>,
source§impl<'param, T, U> RemAssign<&'param Vec2<U>> for Vec2<T>where
T: RemAssign<&'param U>,
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>)
fn rem_assign(&mut self, other: &'param Vec2<U>)
%=
operation. Read moresource§impl<T, U> RemAssign<Vec2<U>> for Vec2<T>where
T: RemAssign<U>,
impl<T, U> RemAssign<Vec2<U>> for Vec2<T>where T: RemAssign<U>,
source§fn rem_assign(&mut self, other: Vec2<U>)
fn rem_assign(&mut self, other: Vec2<U>)
%=
operation. Read moresource§impl<T> SaturatingAdd for Vec2<T>where
T: SaturatingAdd,
impl<T> SaturatingAdd for Vec2<T>where T: SaturatingAdd,
source§fn saturating_add(&self, other: &Self) -> Self
fn saturating_add(&self, other: &Self) -> Self
self + other
, saturating at the relevant high or low boundary of
the type.source§impl<T> SaturatingMul for Vec2<T>where
T: SaturatingMul,
impl<T> SaturatingMul for Vec2<T>where T: SaturatingMul,
source§fn saturating_mul(&self, other: &Self) -> Self
fn saturating_mul(&self, other: &Self) -> Self
self * other
, saturating at the relevant high or low boundary of
the type.source§impl<T> SaturatingSub for Vec2<T>where
T: SaturatingSub,
impl<T> SaturatingSub for Vec2<T>where T: SaturatingSub,
source§fn saturating_sub(&self, other: &Self) -> Self
fn saturating_sub(&self, other: &Self) -> Self
self - other
, saturating at the relevant high or low boundary of
the type.source§impl<T> Signed for Vec2<T>where
T: Signed,
impl<T> Signed for Vec2<T>where T: Signed,
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
source§impl<'this, 'other, T, U> Sub<&'other Vec2<U>> for &'this Vec2<T>where
&'this T: Sub<&'other U>,
impl<'this, 'other, T, U> Sub<&'other Vec2<U>> for &'this Vec2<T>where &'this T: Sub<&'other U>,
source§impl<'param, T, U> SubAssign<&'param Vec2<U>> for Vec2<T>where
T: SubAssign<&'param U>,
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>)
fn sub_assign(&mut self, other: &'param Vec2<U>)
-=
operation. Read moresource§impl<T, U> SubAssign<Vec2<U>> for Vec2<T>where
T: SubAssign<U>,
impl<T, U> SubAssign<Vec2<U>> for Vec2<T>where T: SubAssign<U>,
source§fn sub_assign(&mut self, other: Vec2<U>)
fn sub_assign(&mut self, other: Vec2<U>)
-=
operation. Read moresource§impl<T> WrappingAdd for Vec2<T>where
T: WrappingAdd,
impl<T> WrappingAdd for Vec2<T>where T: WrappingAdd,
source§fn wrapping_add(&self, other: &Self) -> Self
fn wrapping_add(&self, other: &Self) -> Self
self + other
, wrapping around at the boundary of
the type.source§impl<T> WrappingMul for Vec2<T>where
T: WrappingMul,
impl<T> WrappingMul for Vec2<T>where T: WrappingMul,
source§fn wrapping_mul(&self, other: &Self) -> Self
fn wrapping_mul(&self, other: &Self) -> Self
self * other
, wrapping around at the boundary
of the type.source§impl<T> WrappingNeg for Vec2<T>where
T: WrappingNeg,
impl<T> WrappingNeg for Vec2<T>where T: WrappingNeg,
source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self
,
wrapping around at the boundary of the type. Read moresource§impl<T> WrappingSub for Vec2<T>where
T: WrappingSub,
impl<T> WrappingSub for Vec2<T>where T: WrappingSub,
source§fn wrapping_sub(&self, other: &Self) -> Self
fn wrapping_sub(&self, other: &Self) -> Self
self - other
, wrapping around at the boundary
of the type.impl<T: Copy> Copy for Vec2<T>
impl<T: Eq> Eq for Vec2<T>
impl<T> StructuralEq for Vec2<T>
impl<T> StructuralPartialEq for Vec2<T>
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> 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
source§impl<N> ExcessToSigned for Nwhere
N: CastSigned + WrappingSub,
impl<N> ExcessToSigned for Nwhere N: CastSigned + WrappingSub,
source§fn excess_to_signed(&self, excess: &N) -> <N as CastSigned>::Target
fn excess_to_signed(&self, excess: &N) -> <N as CastSigned>::Target
source§fn half_exc_to_signed(&self) -> Self::Targetwhere
Self: HalfExcess,
fn half_exc_to_signed(&self) -> Self::Targetwhere Self: HalfExcess,
N
is half the maximum value of the unsigned input
number.