#[repr(C)]pub struct Vector2<T> {
pub x: T,
pub y: T,
}Expand description
A vector containing two numeric values. This may represent a size or position.
Fields§
§x: TThe horizontal component of the vector.
y: TThe vertical component of the vector.
Implementations§
Source§impl<T: PrimitiveZero> Vector2<T>
impl<T: PrimitiveZero> Vector2<T>
Source§impl<T> Vector2<T>
impl<T> Vector2<T>
Sourcepub fn magnitude_squared(&self) -> T
pub fn magnitude_squared(&self) -> T
Returns the magnitude of the vector, squared.
Source§impl<T: Neg<Output = T> + Copy> Vector2<T>
impl<T: Neg<Output = T> + Copy> Vector2<T>
Sourcepub fn rotate_90_degrees_clockwise(&self) -> Vector2<T>
pub fn rotate_90_degrees_clockwise(&self) -> Vector2<T>
Rotates the vector by 90 degrees in the clockwise direction.
Sourcepub fn rotate_90_degrees_anticlockwise(&self) -> Vector2<T>
pub fn rotate_90_degrees_anticlockwise(&self) -> Vector2<T>
Rotates the vector by 90 degrees in the anti-clockwise direction.
Source§impl<T: AsPrimitive<f32>> Vector2<T>
impl<T: AsPrimitive<f32>> Vector2<T>
Source§impl<T: AsPrimitive<i32>> Vector2<T>
impl<T: AsPrimitive<i32>> Vector2<T>
Source§impl<T: AsPrimitive<u32>> Vector2<T>
impl<T: AsPrimitive<u32>> Vector2<T>
Trait Implementations§
Source§impl<T: Copy + AddAssign, R: Into<Vector2<T>>> AddAssign<R> for Vector2<T>
impl<T: Copy + AddAssign, R: Into<Vector2<T>>> AddAssign<R> for Vector2<T>
Source§fn add_assign(&mut self, rhs: R)
fn add_assign(&mut self, rhs: R)
Performs the
+= operation. Read moreSource§impl<T: Copy + AddAssign, R: Into<Vector2<T>>> AddAssign<R> for &mut Vector2<T>
impl<T: Copy + AddAssign, R: Into<Vector2<T>>> AddAssign<R> for &mut Vector2<T>
Source§fn add_assign(&mut self, rhs: R)
fn add_assign(&mut self, rhs: R)
Performs the
+= operation. Read moreimpl<T: Copy> Copy for Vector2<T>
Source§impl<T: Copy + DivAssign> DivAssign<T> for Vector2<T>
impl<T: Copy + DivAssign> DivAssign<T> for Vector2<T>
Source§fn div_assign(&mut self, divisor: T)
fn div_assign(&mut self, divisor: T)
Performs the
/= operation. Read moreSource§impl<T: Copy + DivAssign> DivAssign<T> for &mut Vector2<T>
impl<T: Copy + DivAssign> DivAssign<T> for &mut Vector2<T>
Source§fn div_assign(&mut self, divisor: T)
fn div_assign(&mut self, divisor: T)
Performs the
/= operation. Read moreimpl<T: Eq> Eq for Vector2<T>
Source§impl<T: Copy + MulAssign> MulAssign<T> for Vector2<T>
impl<T: Copy + MulAssign> MulAssign<T> for Vector2<T>
Source§fn mul_assign(&mut self, factor: T)
fn mul_assign(&mut self, factor: T)
Performs the
*= operation. Read moreSource§impl<T: Copy + MulAssign> MulAssign<T> for &mut Vector2<T>
impl<T: Copy + MulAssign> MulAssign<T> for &mut Vector2<T>
Source§fn mul_assign(&mut self, factor: T)
fn mul_assign(&mut self, factor: T)
Performs the
*= operation. Read moreSource§impl<T: RoundFloat> RoundFloat for Vector2<T>
impl<T: RoundFloat> RoundFloat for Vector2<T>
impl<T: PartialEq> StructuralPartialEq for Vector2<T>
Auto Trait Implementations§
impl<T> Freeze for Vector2<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector2<T>where
T: RefUnwindSafe,
impl<T> Send for Vector2<T>where
T: Send,
impl<T> Sync for Vector2<T>where
T: Sync,
impl<T> Unpin for Vector2<T>where
T: Unpin,
impl<T> UnsafeUnpin for Vector2<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Vector2<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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more