[−][src]Struct riddle_math::Vector2
A basic 2d vector, supporting a small selection of operations
Supported operations (depending on element type):
- Add
- Subtract
- Mul
- Neg (where T: std::ops::Neg)
- Converting to vectors of other element types
Example
let v = vec2(1,2); assert_eq!(vec2(2, 4), v + v); assert_eq!(vec2(0, 0), v - v); assert_eq!(vec2(3, 6), v * 3); assert_eq!(vec2(-1, -2), -v); assert_eq!(vec2(1.0, 2.0), v.convert());
Fields
x: T
y: T
Implementations
impl<T> Vector2<T>
[src]
Trait Implementations
impl<T: SpacialNumeric> Add<Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Vector2<T>) -> Self::Output
[src]
impl<T: SpacialNumeric> AddAssign<Vector2<T>> for Vector2<T>
[src]
fn add_assign(&mut self, rhs: Vector2<T>)
[src]
impl<T: Clone> Clone for Vector2<T>
[src]
impl<T: Copy> Copy for Vector2<T>
[src]
impl<T: Debug> Debug for Vector2<T>
[src]
impl<T: Default> Default for Vector2<T>
[src]
impl<T: PartialEq> Eq for Vector2<T>
[src]
impl<T: Copy> From<[T; 2]> for Vector2<T>
[src]
impl<T> From<Vec2> for Vector2<T> where
f32: SpacialNumericConversion<T>,
[src]
f32: SpacialNumericConversion<T>,
impl<T: Copy> From<Vector2<T>> for Vector2<T>
[src]
impl<T: SpacialNumericConversion<f32>> From<Vector2<T>> for Vec2
[src]
impl<T: SpacialNumeric> Into<Vector2<T>> for Vector2<T>
[src]
impl<T: SpacialNumeric> Mul<T> for Vector2<T>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
impl<T: SignedSpacialNumeric> Neg for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<T: PartialEq> PartialEq<Vector2<T>> for Vector2<T>
[src]
impl<T: SpacialNumericConversion<U>, U> SpacialNumericConversion<Vector2<U>> for Vector2<T>
[src]
Vectors are convertible between numeric types
Example
let v: Vector2<f32> = vec2(3.0, 4.0); let w: Vector2<u32> = v.convert(); assert_eq!(vec2(3, 4), w);
impl<T: SpacialNumeric> Sub<Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector2<T>) -> Self::Output
[src]
impl<T: SpacialNumeric> SubAssign<Vector2<T>> for Vector2<T>
[src]
fn sub_assign(&mut self, rhs: Vector2<T>)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vector2<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vector2<T> where
T: Send,
T: Send,
impl<T> Sync for Vector2<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vector2<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vector2<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,