Struct riddle_math::Vector2[][src]

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

A basic 2d vector, supporting a small selection of operations

Supported operations (depending on element type):

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: Ty: T

Implementations

impl<T> Vector2<T>[src]

pub fn new(x: T, y: T) -> Self[src]

Create a vector with the given coordinatates.

Trait Implementations

impl<T: SpacialNumeric> Add<Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the + operator.

impl<T: SpacialNumeric> AddAssign<Vector2<T>> for 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]

impl<T: Copy> From<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.

impl<T: SignedSpacialNumeric> Neg for Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the - operator.

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.

impl<T: SpacialNumeric> SubAssign<Vector2<T>> for Vector2<T>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.