Vec2

Struct Vec2 

Source
pub struct Vec2<T>
where T: Copy,
{ pub data: [T; 2], }

Fields§

§data: [T; 2]

Implementations§

Source§

impl<T> Vec2<T>
where T: Copy + Default,

Source

pub fn new() -> Vec2<T>

Source§

impl<T> Vec2<T>
where T: Copy,

Source

pub fn from_array(a: [T; 2]) -> Vec2<T>

Source

pub fn from_array_ref(a: &[T; 2]) -> Vec2<T>

Source

pub fn from_slice(s: &[T]) -> Option<Vec2<T>>

Source

pub fn from_map<F>(f: F) -> Vec2<T>
where F: Fn(usize) -> T,

Source

pub fn from_scalar(v: T) -> Vec2<T>

Source§

impl<'a, T> Vec2<T>
where T: Copy,

Source

pub fn iter(&'a self) -> Iter<'a, T>

Source§

impl<'a, T> Vec2<T>
where T: Copy,

Source

pub fn iter_mut(&'a mut self) -> IterMut<'a, T>

Source§

impl<T> Vec2<T>
where T: Copy,

Source

pub fn map<F, S>(self, f: F) -> Vec2<S>
where F: Fn(T) -> S, S: Copy,

Source§

impl<T> Vec2<T>
where T: Copy + Integer,

Source

pub fn div_floor(&self, other: Vec2<T>) -> Vec2<T>

Source

pub fn mod_floor(&self, other: Vec2<T>) -> Vec2<T>

Source

pub fn div_mod_floor(&self, other: Vec2<T>) -> (Vec2<T>, Vec2<T>)

Source§

impl<T> Vec2<T>
where T: Copy + Num,

Source

pub fn sqrlen(self) -> T

Source§

impl<T> Vec2<T>
where T: Copy + Num + Float,

Source

pub fn length(self) -> T

Source

pub fn normalize(self) -> Vec2<T>

Source§

impl<T> Vec2<T>
where T: Copy + Zero,

Source

pub fn zero() -> Vec2<T>

Source

pub fn is_zero(&self) -> bool

Source§

impl Vec2<bool>

Source

pub fn any(self) -> bool

Source§

impl Vec2<bool>

Source

pub fn all(self) -> bool

Source§

impl<T> Vec2<T>
where T: Copy + PartialEq,

Source

pub fn veq(&self, vec: Vec2<T>) -> Vec2<bool>

Source

pub fn vne(&self, vec: Vec2<T>) -> Vec2<bool>

Source§

impl<T> Vec2<T>
where T: Copy + PartialOrd,

Source

pub fn vlt(&self, vec: Vec2<T>) -> Vec2<bool>

Source

pub fn vle(&self, vec: Vec2<T>) -> Vec2<bool>

Source

pub fn vgt(&self, vec: Vec2<T>) -> Vec2<bool>

Source

pub fn vge(&self, vec: Vec2<T>) -> Vec2<bool>

Source§

impl<T> Vec2<T>
where T: Copy + PartialOrd,

Source

pub fn min(&self) -> T

Source

pub fn max(&self) -> T

Source§

impl<T> Vec2<T>
where T: Copy,

Source

pub fn from(v0: T, v1: T) -> Vec2<T>

Source§

impl<T> Vec2<T>
where T: Copy + Num,

Source

pub fn cross(self, vec: Vec2<T>) -> T

Trait Implementations§

Source§

impl<T> Add for Vec2<T>
where T: Copy + Num<Output = T> + Add,

Source§

type Output = Vec2<T>

The resulting type after applying the + operator.
Source§

fn add(self, vec: Vec2<T>) -> <Vec2<T> as Add>::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign for Vec2<T>
where T: Copy + Num<Output = T> + Add,

Source§

fn add_assign(&mut self, vec: Vec2<T>)

Performs the += operation. Read more
Source§

impl BitAnd for Vec2<bool>

Source§

type Output = Vec2<bool>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Vec2<bool>) -> <Vec2<bool> as BitAnd>::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for Vec2<bool>

Source§

fn bitand_assign(&mut self, other: Vec2<bool>)

Performs the &= operation. Read more
Source§

impl BitOr for Vec2<bool>

Source§

type Output = Vec2<bool>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Vec2<bool>) -> <Vec2<bool> as BitOr>::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for Vec2<bool>

Source§

fn bitor_assign(&mut self, other: Vec2<bool>)

Performs the |= operation. Read more
Source§

impl BitXor for Vec2<bool>

Source§

type Output = Vec2<bool>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Vec2<bool>) -> <Vec2<bool> as BitXor>::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Vec2<bool>

Source§

fn bitxor_assign(&mut self, other: Vec2<bool>)

Performs the ^= operation. Read more
Source§

impl<T> Clone for Vec2<T>
where T: Clone + Copy,

Source§

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

Returns a duplicate 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 for Vec2<T>
where T: Debug + Copy,

Source§

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

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

impl<T> Default for Vec2<T>
where T: Copy + Default,

Source§

fn default() -> Vec2<T>

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

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

Source§

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

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

impl<T> Div<T> for Vec2<T>
where T: Copy + Num<Output = T> + Div,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, a: T) -> <Vec2<T> as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<T> Div for Vec2<T>
where T: Copy + Num<Output = T> + Div,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, vec: Vec2<T>) -> <Vec2<T> as Div>::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Vec2<T>
where T: Copy + Num<Output = T> + Div,

Source§

fn div_assign(&mut self, a: T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign for Vec2<T>
where T: Copy + Num<Output = T> + Div,

Source§

fn div_assign(&mut self, vec: Vec2<T>)

Performs the /= operation. Read more
Source§

impl<T> Dot<Mat2x2<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Vec2<T>

Source§

fn dot(self, mat: Mat2x2<T>) -> <Vec2<T> as Dot<Mat2x2<T>>>::Output

Source§

impl<T> Dot<Mat3x2<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Vec3<T>

Source§

fn dot(self, mat: Mat3x2<T>) -> <Vec2<T> as Dot<Mat3x2<T>>>::Output

Source§

impl<T> Dot<Mat4x2<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Vec4<T>

Source§

fn dot(self, mat: Mat4x2<T>) -> <Vec2<T> as Dot<Mat4x2<T>>>::Output

Source§

impl<T> Dot<Vec2<T>> for Mat2x2<T>
where T: Copy + Num,

Source§

type Output = Vec2<T>

Source§

fn dot(self, vec: Vec2<T>) -> <Mat2x2<T> as Dot<Vec2<T>>>::Output

Source§

impl<T> Dot<Vec2<T>> for Mat2x3<T>
where T: Copy + Num,

Source§

type Output = Vec3<T>

Source§

fn dot(self, vec: Vec2<T>) -> <Mat2x3<T> as Dot<Vec2<T>>>::Output

Source§

impl<T> Dot<Vec2<T>> for Mat2x4<T>
where T: Copy + Num,

Source§

type Output = Vec4<T>

Source§

fn dot(self, vec: Vec2<T>) -> <Mat2x4<T> as Dot<Vec2<T>>>::Output

Source§

impl<T> Dot<Vec2<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = T

Source§

fn dot(self, vec: Vec2<T>) -> <Vec2<T> as Dot<Vec2<T>>>::Output

Source§

impl<T> Index<usize> for Vec2<T>
where T: Copy,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &<Vec2<T> as Index<usize>>::Output

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

impl<T> IndexMut<usize> for Vec2<T>
where T: Copy,

Source§

fn index_mut(&mut self, i: usize) -> &mut <Vec2<T> as Index<usize>>::Output

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

impl<'a, T> IntoIterator for &'a Vec2<T>
where T: Copy,

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a Vec2<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut Vec2<T>
where T: Copy,

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a mut Vec2<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> Mul<T> for Vec2<T>
where T: Copy + Num<Output = T> + Mul,

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, a: T) -> <Vec2<T> as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<T> Mul for Vec2<T>
where T: Copy + Num<Output = T> + Mul,

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, vec: Vec2<T>) -> <Vec2<T> as Mul>::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Vec2<T>
where T: Copy + Num<Output = T> + Mul,

Source§

fn mul_assign(&mut self, a: T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Vec2<T>
where T: Copy + Num<Output = T> + Mul,

Source§

fn mul_assign(&mut self, vec: Vec2<T>)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vec2<T>
where T: Copy + Num + Signed,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> <Vec2<T> as Neg>::Output

Performs the unary - operation. Read more
Source§

impl Not for Vec2<bool>

Source§

type Output = Vec2<bool>

The resulting type after applying the ! operator.
Source§

fn not(self) -> <Vec2<bool> as Not>::Output

Performs the unary ! operation. Read more
Source§

impl<T> Outer<Vec2<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Mat2x2<T>

Source§

fn outer(self, vec: Vec2<T>) -> <Vec2<T> as Outer<Vec2<T>>>::Output

Source§

impl<T> Outer<Vec2<T>> for Vec3<T>
where T: Copy + Num,

Source§

type Output = Mat2x3<T>

Source§

fn outer(self, vec: Vec2<T>) -> <Vec3<T> as Outer<Vec2<T>>>::Output

Source§

impl<T> Outer<Vec2<T>> for Vec4<T>
where T: Copy + Num,

Source§

type Output = Mat2x4<T>

Source§

fn outer(self, vec: Vec2<T>) -> <Vec4<T> as Outer<Vec2<T>>>::Output

Source§

impl<T> Outer<Vec3<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Mat3x2<T>

Source§

fn outer(self, vec: Vec3<T>) -> <Vec2<T> as Outer<Vec3<T>>>::Output

Source§

impl<T> Outer<Vec4<T>> for Vec2<T>
where T: Copy + Num,

Source§

type Output = Mat4x2<T>

Source§

fn outer(self, vec: Vec4<T>) -> <Vec2<T> as Outer<Vec4<T>>>::Output

Source§

impl<T> PartialEq for Vec2<T>
where T: PartialEq + Copy,

Source§

fn eq(&self, other: &Vec2<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<T> Rem<T> for Vec2<T>
where T: Copy + Num<Output = T> + Rem,

Source§

type Output = Vec2<T>

The resulting type after applying the % operator.
Source§

fn rem(self, a: T) -> <Vec2<T> as Rem<T>>::Output

Performs the % operation. Read more
Source§

impl<T> Rem for Vec2<T>
where T: Copy + Num<Output = T> + Rem,

Source§

type Output = Vec2<T>

The resulting type after applying the % operator.
Source§

fn rem(self, vec: Vec2<T>) -> <Vec2<T> as Rem>::Output

Performs the % operation. Read more
Source§

impl<T> RemAssign<T> for Vec2<T>
where T: Copy + Num<Output = T> + Rem,

Source§

fn rem_assign(&mut self, a: T)

Performs the %= operation. Read more
Source§

impl<T> RemAssign for Vec2<T>
where T: Copy + Num<Output = T> + Rem,

Source§

fn rem_assign(&mut self, vec: Vec2<T>)

Performs the %= operation. Read more
Source§

impl<T> Sub for Vec2<T>
where T: Copy + Num<Output = T> + Sub,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn sub(self, vec: Vec2<T>) -> <Vec2<T> as Sub>::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign for Vec2<T>
where T: Copy + Num<Output = T> + Sub,

Source§

fn sub_assign(&mut self, vec: Vec2<T>)

Performs the -= operation. Read more
Source§

impl<T> Zero for Vec2<T>
where T: Copy + Num + Zero,

Source§

fn zero() -> Vec2<T>

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 for Vec2<T>
where T: Copy,

Source§

impl<T> StructuralPartialEq for Vec2<T>
where T: Copy,

Auto Trait Implementations§

§

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

§

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 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> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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