Struct gfxmath_vec2::Vec2

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

Fields§

§x: T§y: T

Implementations§

source§

impl<T> Vec2<T>

source

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

source

pub fn as_ptr(&self) -> *const T

source

pub fn as_mut_ptr(&mut self) -> *mut T

source

pub fn as_slice(&self) -> &[T]

use gfxmath_vec2::Vec2;
 
let a = Vec2::<f32>::new(1.0, 2.0);
 
let a_slice = a.as_slice();
 
assert_eq!(1.0, a_slice[0]);
assert_eq!(2.0, a_slice[1]);
source

pub fn as_mut_slice(&mut self) -> &mut [T]

use gfxmath_vec2::Vec2;
 
let mut a = Vec2::<f32>::new(1.0, 2.0);
 
{
    let a_slice = a.as_mut_slice();
 
    assert_eq!(1.0, a_slice[0]);
    assert_eq!(2.0, a_slice[1]);
 
    a_slice[1] = 108.0;
    assert_eq!(108.0, a_slice[1]); 
}
 
a.x = 4.5;
assert_eq!(4.5, a.x);
 
let a_slice = a.as_mut_slice();
 
assert_eq!(4.5, a_slice[0]);
assert_eq!(108.0, a_slice[1]);
source§

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

source

pub fn all(val: T) -> Self

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f32>::all(2.5);
 
assert_eq!(2.5, v.x);
assert_eq!(2.5, v.y);

Trait Implementations§

source§

impl<T> Add<&Vec2<T>> for &Vec2<T>where T: Add<Output = T> + Clone,

§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> Add<&Vec2<T>> for Vec2<T>where T: Add<Output = T> + Clone,

§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<&Vec2<f32>> for f32

§

type Output = Vec2<f32>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec2<f32>) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vec2<f64>> for f64

§

type Output = Vec2<f64>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec2<f64>) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vec2<i32>> for i32

§

type Output = Vec2<i32>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec2<i32>) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vec2<i64>> for i64

§

type Output = Vec2<i64>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec2<i64>) -> Self::Output

Performs the + operation. Read more
source§

impl<T> Add<T> for &Vec2<T>where T: Add<Output = T> + Clone,

§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f32>::new(1.0, 2.0);

let res: Vec2<f32> = (v + 3.0).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

impl<T> Add<Vec2<T>> for &Vec2<T>where T: Add<Output = T> + Clone,

§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

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

source§

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

use gfxmath_vec2::Vec2;
let a = Vec2::new(1.0, 2.0);
let b = Vec2::new(3.0, 4.0);
 
let res = &a + &b;
 
assert_eq!(1.0, a.x);
assert_eq!(2.0, a.y);
 
assert_eq!(3.0, b.x);
assert_eq!(4.0, b.y);
 
assert_eq!(4.0, res.x);
assert_eq!(6.0, res.y);
§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

impl Add<Vec2<f32>> for f32

source§

fn add(self, rhs: Vec2<f32>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f32>::new(1.0, 2.0);

let res: Vec2<f32> = (3.0 + v).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
§

type Output = Vec2<f32>

The resulting type after applying the + operator.
source§

impl Add<Vec2<f64>> for f64

source§

fn add(self, rhs: Vec2<f64>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f64>::new(1.0, 2.0);

let res: Vec2<f64> = (3.0 + v).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
§

type Output = Vec2<f64>

The resulting type after applying the + operator.
source§

impl Add<Vec2<i32>> for i32

source§

fn add(self, rhs: Vec2<i32>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<i32>::new(1, 2);

let res: Vec2<i32> = (3 + v).into();
 
assert_eq!(4, res.x);
assert_eq!(5, res.y);
§

type Output = Vec2<i32>

The resulting type after applying the + operator.
source§

impl Add<Vec2<i64>> for i64

source§

fn add(self, rhs: Vec2<i64>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<i64>::new(1, 2);

let res: Vec2<i64> = (3 + v).into();
 
assert_eq!(4, res.x);
assert_eq!(5, res.y);
§

type Output = Vec2<i64>

The resulting type after applying the + operator.
source§

impl<T> AddAssign<&Vec2<T>> for Vec2<T>where T: AddAssign<T> + Copy,

source§

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

Performs the += operation. Read more
source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = (2.0, 5.0);
v1 += v2;
 
assert_eq!(3.0, v1.x);
assert_eq!(8.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = (3.5, 2.0);
 
*(&mut v1) += v2;
 
assert_eq!(12.5, v1.x);
assert_eq!(7.0, v1.y);
source§

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

Performs the += operation. Read more
source§

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

source§

fn add_assign(&mut self, rhs: T)

use gfxmath_vec2::Vec2;
  
let mut v1 = Vec2::new(9.0, 5.0);
 
v1 += 2.0;
 
assert_eq!(11.0, v1.x);
assert_eq!(7.0, v1.y);
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = Vec2::new(2.0, 5.0);
v1 += v2;
 
assert_eq!(3.0, v1.x);
assert_eq!(8.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = Vec2::new(3.5, 2.0);
 
*(&mut v1) += v2;
 
assert_eq!(12.5, v1.x);
assert_eq!(7.0, v1.y);
source§

impl<T: Clone> Clone for Vec2<T>

source§

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

source§

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

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

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

§

type Output = Vec2<T>

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 Vec2<T>where T: Div<Output = T> + Copy,

source§

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

Scalar division with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<f32>::new(0.5, 2.5);
let b = a / 2.0;
 
assert_eq!( 0.25, b.x);
assert_eq!( 1.25, b.y);
§

type Output = Vec2<T>

The resulting type after applying the / operator.
source§

impl<T> DivAssign<&Vec2<T>> for Vec2<T>where T: DivAssign<T> + Copy,

source§

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

Performs the /= operation. Read more
source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = (2.0, 5.0);
v1 /= v2;
 
assert_eq!(0.5, v1.x);
assert_eq!(0.6, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = (2.5, 2.0);
 
*(&mut v1) /= v2;
 
assert_eq!(3.6, v1.x);
assert_eq!(2.5, v1.y);
source§

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

Performs the /= operation. Read more
source§

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

source§

fn div_assign(&mut self, rhs: T)

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(9.0, 5.0);
 
v1 /= 2.0;
 
assert_eq!(4.5, v1.x);
assert_eq!(2.5, v1.y);
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = Vec2::new(2.0, 5.0);
v1 /= v2;
 
assert_eq!(0.5, v1.x);
assert_eq!(0.6, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = Vec2::new(2.5, 2.0);
 
*(&mut v1) /= v2;
 
assert_eq!(3.6, v1.x);
assert_eq!(2.5, v1.y);
source§

impl<T> From<&(T, T)> for Vec2<T>where T: Clone,

use gfxmath_vec2::Vec2;
 
let v0 = (3.0, 2.0);
 
let v: Vec2<f32> = (&v0).into();
 
assert_eq!(3.0, v.x);
assert_eq!(2.0, v.y);
source§

fn from(val: &(T, T)) -> Self

Converts to this type from the input type.
source§

impl<T> From<&Vec2<T>> for (T, T)where T: Clone,

use gfxmath_vec2::Vec2;
 
let v = Vec2::new(3.0, 2.0);
let v: (f32, f32) = (&v).into();
 
assert_eq!(3.0, v.0);
assert_eq!(2.0, v.1);
source§

fn from(val: &Vec2<T>) -> Self

Converts to this type from the input type.
source§

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

use gfxmath_vec2::Vec2;
 
let v: Vec2<f32> = (3.0, 2.0).into();
 
assert_eq!(3.0, v.x);
assert_eq!(2.0, v.y);
source§

fn from(val: (T, T)) -> Self

Converts to this type from the input type.
source§

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

use gfxmath_vec2::Vec2;
 
let v = Vec2::new(3.0, 2.0);
let v: (f32, f32) = v.into();
 
assert_eq!(3.0, v.0);
assert_eq!(2.0, v.1);
 
source§

fn from(val: Vec2<T>) -> Self

Converts to this type from the input type.
source§

impl Hash for Vec2<f32>

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 Hash for Vec2<f64>

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 Hash for Vec2<i32>

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 Hash for Vec2<i64>

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 Hash for Vec2<u32>

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 Hash for Vec2<u64>

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> Mul<&Vec2<T>> for &Vec2<T>where T: Mul<Output = T> + Copy,

§

type Output = Vec2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Vec2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<&Vec2<f32>> for f32

§

type Output = Vec2<f32>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Vec2<f32>) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<&Vec2<f64>> for f64

§

type Output = Vec2<f64>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Vec2<f64>) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<&Vec2<i32>> for i32

§

type Output = Vec2<i32>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Vec2<i32>) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<&Vec2<i64>> for i64

§

type Output = Vec2<i64>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Vec2<i64>) -> Self::Output

Performs the * operation. Read more
source§

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

§

type Output = Vec2<T>

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 Vec2<T>where T: Mul<Output = T> + Copy,

source§

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

Scalar multiplication with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<f32>::new(0.5, 2.5);
let b = Vec2::from(a * 2.0);
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
§

type Output = Vec2<T>

The resulting type after applying the * operator.
source§

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

§

type Output = Vec2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut a = Vec2::<f32>::new(1.5, 2.5);
let b = Vec2::<f32>::new(4.0, 2.0);
let c = &a * &b;
 
a.x = 2.0;
 
assert_eq!( 6.0, c.x);
assert_eq!( 5.0, c.y);
 
let c = a * b;

assert_eq!( 8.0, c.x);
assert_eq!( 5.0, c.y);
§

type Output = Vec2<T>

The resulting type after applying the * operator.
source§

impl Mul<Vec2<f32>> for f32

source§

fn mul(self, rhs: Vec2<f32>) -> Self::Output

Scalar multiplication with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<f32>::new(0.5, 2.5);
let b = 2.0 * a;
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
§

type Output = Vec2<f32>

The resulting type after applying the * operator.
source§

impl Mul<Vec2<f64>> for f64

source§

fn mul(self, rhs: Vec2<f64>) -> Self::Output

Scalar multiplication with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<f64>::new(0.5, 2.5);
let b = 2.0 * a;
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
§

type Output = Vec2<f64>

The resulting type after applying the * operator.
source§

impl Mul<Vec2<i32>> for i32

source§

fn mul(self, rhs: Vec2<i32>) -> Self::Output

Scalar multiplication with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<i32>::new(5, 2);
let b = 2 * a;
 
assert_eq!( 10, b.x);
assert_eq!( 4, b.y);
§

type Output = Vec2<i32>

The resulting type after applying the * operator.
source§

impl Mul<Vec2<i64>> for i64

source§

fn mul(self, rhs: Vec2<i64>) -> Self::Output

Scalar multiplication with vector

use gfxmath_vec2::Vec2;
 
let a = Vec2::<i64>::new(5, 2);
let b = 2 * a;
 
assert_eq!( 10, b.x);
assert_eq!( 4, b.y);
§

type Output = Vec2<i64>

The resulting type after applying the * operator.
source§

impl<T> MulAssign<&Vec2<T>> for Vec2<T>where T: MulAssign<T> + Copy,

source§

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

Performs the *= operation. Read more
source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = (2.0, 5.0);
v1 *= v2;
 
assert_eq!(2.0, v1.x);
assert_eq!(15.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = (3.5, 2.0);
 
*(&mut v1) *= v2;
 
assert_eq!(31.5, v1.x);
assert_eq!(10.0, v1.y);
source§

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

Performs the *= operation. Read more
source§

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

source§

fn mul_assign(&mut self, rhs: T)

use gfxmath_vec2::Vec2;
  
let mut v1 = Vec2::new(9.0, 5.0);
 
v1 *= 2.0;
 
assert_eq!(18.0, v1.x);
assert_eq!(10.0, v1.y);
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = Vec2::new(2.0, 5.0);
v1 *= v2;
 
assert_eq!(2.0, v1.x);
assert_eq!(15.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = Vec2::new(3.5, 2.0);
 
*(&mut v1) *= v2;
 
assert_eq!(31.5, v1.x);
assert_eq!(10.0, v1.y);
source§

impl<T> Neg for &Vec2<T>where T: Neg<Output = T> + Copy,

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

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

source§

fn neg(self) -> Self::Output

Scalar multiplication with vector

use gfxmath_vec2::Vec2;

let a = Vec2::<f32>::new(2.0, 6.0);
 
let res = -a;

assert_eq!(-2.0, res.x);
assert_eq!(-6.0, res.y);
§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

impl Norm for &Vec2<f32>

§

type Output = Option<Vec2<f32>>

source§

fn norm(self) -> Self::Output

source§

impl Norm for &Vec2<f64>

§

type Output = Option<Vec2<f64>>

source§

fn norm(self) -> Self::Output

source§

impl Norm for Vec2<f32>

source§

fn norm(self) -> Self::Output

use gfxmath_vec2::ops::Norm;
use gfxmath_vec2::Vec2;
 
let a = Vec2::<f32>::new(3.0, 4.0);
let an = a.norm().unwrap();
 
assert_eq!(3.0/5.0, an.x);
assert_eq!(4.0/5.0, an.y);
§

type Output = Option<Vec2<f32>>

source§

impl Norm for Vec2<f64>

source§

fn norm(self) -> Self::Output

use gfxmath_vec2::ops::Norm;
use gfxmath_vec2::Vec2;
 
let a = Vec2::<f64>::new(3.0, 4.0);
let an = a.norm().unwrap();
 
assert_eq!(3.0/5.0, an.x);
assert_eq!(4.0/5.0, an.y);
§

type Output = Option<Vec2<f64>>

source§

impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Sub<Output = T> + Copy> Sub<&Vec2<T>> for &Vec2<T>

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Sub<Output = T> + Copy> Sub<&Vec2<T>> for Vec2<T>

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<&Vec2<f32>> for f32

§

type Output = Vec2<f32>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec2<f32>) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vec2<f64>> for f64

§

type Output = Vec2<f64>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec2<f64>) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vec2<i32>> for i32

§

type Output = Vec2<i32>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec2<i32>) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vec2<i64>> for i64

§

type Output = Vec2<i64>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec2<i64>) -> Self::Output

Performs the - operation. Read more
source§

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

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let v = Vec2::new(1.0, 2.0);

let res: Vec2<f32> = (v - 3.0).into();
 
assert_eq!(-2.0, res.x);
assert_eq!(-1.0, res.y);
§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

impl<T: Sub<Output = T> + Copy> Sub<Vec2<T>> for &Vec2<T>

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut a = Vec2::<f32>::new(0.5, 2.5);
let b = Vec2::<f32>::new(1.5, 2.5);
let c = Vec2::from(&a - &b);
 
a.x = 1.0;
 
assert_eq!(-1.0, c.x);
assert_eq!( 0.0, c.y);
 
let c2 = Vec2::from(a - b);

assert_eq!(-0.5, c2.x);
assert_eq!( 0.0, c2.y);
§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

impl Sub<Vec2<f32>> for f32

source§

fn sub(self, rhs: Vec2<f32>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f32>::new(1.0, 2.0);

let res = (3.0 - v);
 
assert_eq!( 2.0, res.x);
assert_eq!( 1.0, res.y);
§

type Output = Vec2<f32>

The resulting type after applying the - operator.
source§

impl Sub<Vec2<f64>> for f64

source§

fn sub(self, rhs: Vec2<f64>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<f32>::new(1.0, 2.0);

let res = (3.0 - v);
 
assert_eq!( 2.0, res.x);
assert_eq!( 1.0, res.y);
§

type Output = Vec2<f64>

The resulting type after applying the - operator.
source§

impl Sub<Vec2<i32>> for i32

source§

fn sub(self, rhs: Vec2<i32>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<i32>::new(1, 2);

let res = (3 - v);
 
assert_eq!( 2, res.x);
assert_eq!( 1, res.y);
§

type Output = Vec2<i32>

The resulting type after applying the - operator.
source§

impl Sub<Vec2<i64>> for i64

source§

fn sub(self, rhs: Vec2<i64>) -> Self::Output

use gfxmath_vec2::Vec2;
 
let v = Vec2::<i64>::new(1, 2);

let res = (3 - v);
 
assert_eq!( 2, res.x);
assert_eq!( 1, res.y);
§

type Output = Vec2<i64>

The resulting type after applying the - operator.
source§

impl<T> SubAssign<&Vec2<T>> for Vec2<T>where T: SubAssign<T> + Copy,

source§

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

Performs the -= operation. Read more
source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = (2.0, 5.0);
v1 -= v2;
 
assert_eq!(-1.0, v1.x);
assert_eq!(-2.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = (3.5, 2.0);
 
*(&mut v1) -= v2;
 
assert_eq!(5.5, v1.x);
assert_eq!(3.0, v1.y);
source§

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

Performs the -= operation. Read more
source§

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

source§

fn sub_assign(&mut self, rhs: T)

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
v1 -= 2.0;
 
assert_eq!(-1.0, v1.x);
assert_eq!( 1.0, v1.y);
source§

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

source§

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

use gfxmath_vec2::Vec2;
 
let mut v1 = Vec2::new(1.0, 3.0);
let v2 = Vec2::new(2.0, 5.0);
v1 -= v2;
 
assert_eq!(-1.0, v1.x);
assert_eq!(-2.0, v1.y);
 
let mut v1 = Vec2::new(9.0, 5.0);
let v2 = Vec2::new(3.5, 2.0);
 
*(&mut v1) -= v2;
 
assert_eq!(5.5, v1.x);
assert_eq!(3.0, v1.y);
source§

impl<T> Eq for Vec2<T>where T: PartialEq,

source§

impl<T> StructuralPartialEq for Vec2<T>

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.