Struct Vector2

Source
#[repr(C)]
pub struct Vector2<T> { pub x: T, pub y: T, }
Expand description

2-dimensional vector type.

Fields§

§x: T§y: T

Implementations§

Source§

impl<T> Vector2<T>

Source

pub const fn new(x: T, y: T) -> Vector2<T>

Constructs a vector from its scalar parts.

Trait Implementations§

Source§

impl<'a, 'b, T> Add<&'b Vector2<T>> for &'a Vector2<T>
where &'a T: Add<&'b T>,

Source§

type Output = Vector2<<&'a T as Add<&'b T>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Vector2<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<&'a Vector2<T>> for Vector2<T>
where T: Add<&'a T>,

Source§

type Output = Vector2<<T as Add<&'a T>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Vector2<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<[T; 2]> for &'a Vector2<T>
where &'a T: Add<T>,

Source§

type Output = Vector2<<&'a T as Add<T>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: [T; 2]) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<[T; 2]> for Vector2<T>
where T: Add,

Source§

type Output = Vector2<<T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: [T; 2]) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<(T, T)> for &'a Vector2<T>
where &'a T: Add<T>,

Source§

type Output = Vector2<<&'a T as Add<T>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: (T, T)) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<(T, T)> for Vector2<T>
where T: Add,

Source§

type Output = Vector2<<T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: (T, T)) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<Vector2<T>> for &'a Vector2<T>
where &'a T: Add<T>,

Source§

type Output = Vector2<<&'a T as Add<T>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector2<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for Vector2<T>
where T: Add,

Source§

type Output = Vector2<<T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector2<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> AddAssign<&'a Vector2<T>> for Vector2<T>
where T: AddAssign<&'a T>,

Source§

fn add_assign(&mut self, rhs: &'a Vector2<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign<[T; 2]> for Vector2<T>
where T: AddAssign,

Source§

fn add_assign(&mut self, rhs: [T; 2])

Performs the += operation. Read more
Source§

impl<T> AddAssign<(T, T)> for Vector2<T>
where T: AddAssign,

Source§

fn add_assign(&mut self, rhs: (T, T))

Performs the += operation. Read more
Source§

impl<T> AddAssign for Vector2<T>
where T: AddAssign,

Source§

fn add_assign(&mut self, rhs: Vector2<T>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Vector2<T>

Source§

fn clone(&self) -> Vector2<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 Vector2<T>

Source§

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

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

impl<'a, 'b, T> Div<&'b T> for &'a Vector2<T>
where &'a T: Div<&'b T>,

Source§

type Output = Vector2<<&'a T as Div<&'b T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b T) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<&'a T> for Vector2<T>
where T: Div<&'a T>,

Source§

type Output = Vector2<<T as Div<&'a T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a T) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, 'b, T> Div<&'b Vector2<T>> for &'a Vector2<T>
where &'a T: Div<&'b T>,

Source§

type Output = Vector2<<&'a T as Div<&'b T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b Vector2<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<&'a Vector2<T>> for Vector2<T>
where T: Div<&'a T>,

Source§

type Output = Vector2<<T as Div<&'a T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Vector2<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<[T; 2]> for &'a Vector2<T>
where &'a T: Div<T>,

Source§

type Output = Vector2<<&'a T as Div<T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: [T; 2]) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<[T; 2]> for Vector2<T>
where T: Div,

Source§

type Output = Vector2<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: [T; 2]) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<(T, T)> for &'a Vector2<T>
where &'a T: Div<T>,

Source§

type Output = Vector2<<&'a T as Div<T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: (T, T)) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<(T, T)> for Vector2<T>
where T: Div,

Source§

type Output = Vector2<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: (T, T)) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<T> for &'a Vector2<T>
where T: Copy, &'a T: Div<T>,

Source§

type Output = Vector2<<&'a T as Div<T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for Vector2<T>
where T: Copy + Div,

Source§

type Output = Vector2<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<Vector2<T>> for &'a Vector2<T>
where &'a T: Div<T>,

Source§

type Output = Vector2<<&'a T as Div<T>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vector2<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div for Vector2<T>
where T: Div,

Source§

type Output = Vector2<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vector2<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> DivAssign<&'a T> for Vector2<T>
where T: DivAssign<&'a T>,

Source§

fn div_assign(&mut self, rhs: &'a T)

Performs the /= operation. Read more
Source§

impl<'a, T> DivAssign<&'a Vector2<T>> for Vector2<T>
where T: DivAssign<&'a T>,

Source§

fn div_assign(&mut self, rhs: &'a Vector2<T>)

Performs the /= operation. Read more
Source§

impl<T> DivAssign<[T; 2]> for Vector2<T>
where T: DivAssign,

Source§

fn div_assign(&mut self, rhs: [T; 2])

Performs the /= operation. Read more
Source§

impl<T> DivAssign<(T, T)> for Vector2<T>
where T: DivAssign,

Source§

fn div_assign(&mut self, rhs: (T, T))

Performs the /= operation. Read more
Source§

impl<T> DivAssign<T> for Vector2<T>
where T: Copy + DivAssign,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign for Vector2<T>
where T: DivAssign,

Source§

fn div_assign(&mut self, rhs: Vector2<T>)

Performs the /= operation. Read more
Source§

impl<T> From<[T; 2]> for Vector2<T>

Source§

fn from(array: [T; 2]) -> Vector2<T>

Converts to this type from the input type.
Source§

impl<T> From<(T, T)> for Vector2<T>

Source§

fn from(tuple: (T, T)) -> Vector2<T>

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Vector2<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> Into<[T; 2]> for Vector2<T>

Source§

fn into(self) -> [T; 2]

Converts this type into the (usually inferred) input type.
Source§

impl<T> Into<(T, T)> for Vector2<T>

Source§

fn into(self) -> (T, T)

Converts this type into the (usually inferred) input type.
Source§

impl<'a, 'b, T> Mul<&'b T> for &'a Vector2<T>
where &'a T: Mul<&'b T>,

Source§

type Output = Vector2<<&'a T as Mul<&'b T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b T) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<&'a T> for Vector2<T>
where T: Mul<&'a T>,

Source§

type Output = Vector2<<T as Mul<&'a T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a T) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, 'b, T> Mul<&'b Vector2<T>> for &'a Vector2<T>
where &'a T: Mul<&'b T>,

Source§

type Output = Vector2<<&'a T as Mul<&'b T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Vector2<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<&'a Vector2<T>> for Vector2<T>
where T: Mul<&'a T>,

Source§

type Output = Vector2<<T as Mul<&'a T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Vector2<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<[T; 2]> for &'a Vector2<T>
where &'a T: Mul<T>,

Source§

type Output = Vector2<<&'a T as Mul<T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: [T; 2]) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<[T; 2]> for Vector2<T>
where T: Mul,

Source§

type Output = Vector2<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: [T; 2]) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<(T, T)> for &'a Vector2<T>
where &'a T: Mul<T>,

Source§

type Output = Vector2<<&'a T as Mul<T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: (T, T)) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<(T, T)> for Vector2<T>
where T: Mul,

Source§

type Output = Vector2<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: (T, T)) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<T> for &'a Vector2<T>
where T: Copy, &'a T: Mul<T>,

Source§

type Output = Vector2<<&'a T as Mul<T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for Vector2<T>
where T: Copy + Mul,

Source§

type Output = Vector2<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<Vector2<T>> for &'a Vector2<T>
where &'a T: Mul<T>,

Source§

type Output = Vector2<<&'a T as Mul<T>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector2<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul for Vector2<T>
where T: Mul,

Source§

type Output = Vector2<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector2<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> MulAssign<&'a T> for Vector2<T>
where T: MulAssign<&'a T>,

Source§

fn mul_assign(&mut self, rhs: &'a T)

Performs the *= operation. Read more
Source§

impl<'a, T> MulAssign<&'a Vector2<T>> for Vector2<T>
where T: MulAssign<&'a T>,

Source§

fn mul_assign(&mut self, rhs: &'a Vector2<T>)

Performs the *= operation. Read more
Source§

impl<T> MulAssign<[T; 2]> for Vector2<T>
where T: MulAssign,

Source§

fn mul_assign(&mut self, rhs: [T; 2])

Performs the *= operation. Read more
Source§

impl<T> MulAssign<(T, T)> for Vector2<T>
where T: MulAssign,

Source§

fn mul_assign(&mut self, rhs: (T, T))

Performs the *= operation. Read more
Source§

impl<T> MulAssign<T> for Vector2<T>
where T: Copy + MulAssign,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Vector2<T>
where T: MulAssign,

Source§

fn mul_assign(&mut self, rhs: Vector2<T>)

Performs the *= operation. Read more
Source§

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

Source§

type Output = Vector2<<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: PartialEq> PartialEq for Vector2<T>

Source§

fn eq(&self, other: &Vector2<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b, T> Sub<&'b Vector2<T>> for &'a Vector2<T>
where &'a T: Sub<&'b T>,

Source§

type Output = Vector2<<&'a T as Sub<&'b T>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Vector2<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<&'a Vector2<T>> for Vector2<T>
where T: Sub<&'a T>,

Source§

type Output = Vector2<<T as Sub<&'a T>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Vector2<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<[T; 2]> for &'a Vector2<T>
where &'a T: Sub<T>,

Source§

type Output = Vector2<<&'a T as Sub<T>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: [T; 2]) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<[T; 2]> for Vector2<T>
where T: Sub,

Source§

type Output = Vector2<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: [T; 2]) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<(T, T)> for &'a Vector2<T>
where &'a T: Sub<T>,

Source§

type Output = Vector2<<&'a T as Sub<T>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: (T, T)) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<(T, T)> for Vector2<T>
where T: Sub,

Source§

type Output = Vector2<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: (T, T)) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<Vector2<T>> for &'a Vector2<T>
where &'a T: Sub<T>,

Source§

type Output = Vector2<<&'a T as Sub<T>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector2<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub for Vector2<T>
where T: Sub,

Source§

type Output = Vector2<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector2<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> SubAssign<&'a Vector2<T>> for Vector2<T>
where T: SubAssign<&'a T>,

Source§

fn sub_assign(&mut self, rhs: &'a Vector2<T>)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<[T; 2]> for Vector2<T>
where T: SubAssign,

Source§

fn sub_assign(&mut self, rhs: [T; 2])

Performs the -= operation. Read more
Source§

impl<T> SubAssign<(T, T)> for Vector2<T>
where T: SubAssign,

Source§

fn sub_assign(&mut self, rhs: (T, T))

Performs the -= operation. Read more
Source§

impl<T> SubAssign for Vector2<T>
where T: SubAssign,

Source§

fn sub_assign(&mut self, rhs: Vector2<T>)

Performs the -= operation. Read more
Source§

impl<T: Copy> Copy for Vector2<T>

Source§

impl<T: Eq> Eq for Vector2<T>

Source§

impl<T> 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> UnwindSafe for Vector2<T>
where T: 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.