#[repr(C)]pub struct Vec2 {
pub x: f32,
pub y: f32,
}
Expand description
A vector with 2 components: x and y. This can represent a point in 2D space, a directional vector, or any other sort of value with 2 dimensions to it! https://stereokit.net/Pages/StereoKit/Vec2.html
see also glam::Vec2
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 2.0);
let vec2a = Vec2 { x: 1.0, y: 2.0 };
let vec2b = Vec2::X + Vec2::Y * 2.0;
let vec3c: Vec2 = [1.0, 2.0].into();
assert_eq!(vec2, vec2a);
assert_eq!(vec2a + vec2b, Vec2 { x: 2.0, y: 4.0 });
assert_eq!(vec3c, Vec2 { x: 1.0, y: 2.0 });
assert_eq!(vec2a.length_sq(), 5.0);
assert_eq!(Vec2::Y.angle(), 90.0);
assert_eq!(vec2a.magnitude(), (5.0f32).sqrt());
assert! (vec2a.get_normalized().length() - 1.0 < f32::EPSILON);
assert_eq!(Vec2::angle_between(Vec2::X, Vec2::Y), 90.0);
assert_eq!(Vec2::dot(Vec2::X, Vec2::Y), 0.0);
Fields§
§x: f32
§y: f32
Implementations§
Source§impl Vec2
impl Vec2
Sourcepub const ZERO: Self
pub const ZERO: Self
A Vec2 with all components at zero, this is the same as new Vec2(0,0). https://stereokit.net/Pages/StereoKit/Vec2/Zero.html
Sourcepub const ONE: Self
pub const ONE: Self
A Vec2 with all components at one, this is the same as new Vec2(1,1). https://stereokit.net/Pages/StereoKit/Vec2/One.html
Sourcepub const X: Self
pub const X: Self
A normalized Vector that points down the X axis, this is the same as new Vec2(1,0). https://stereokit.net/Pages/StereoKit/Vec2/UnitX.html
Sourcepub const Y: Self
pub const Y: Self
A normalized Vector that points down the Y axis, this is the same as new Vec2(0,1). https://stereokit.net/Pages/StereoKit/Vec2/UnitY.html
Sourcepub const NEG_X: Self
pub const NEG_X: Self
A normalized Vector that points up the X axis, this is the same as new Vec2(-1,0).
Sourcepub const NEG_Y: Self
pub const NEG_Y: Self
A normalized Vector that points up the Y axis, this is the same as new Vec2(0,-1).
Sourcepub const fn new(x: f32, y: f32) -> Self
pub const fn new(x: f32, y: f32) -> Self
A basic constructor, just copies the values in! https://stereokit.net/Pages/StereoKit/Vec2/Vec2.html
Sourcepub fn angle(&self) -> f32
pub fn angle(&self) -> f32
Returns the counter-clockwise degrees from [1,0]
. Resulting value is between 0 and 360. Vector does not need
to be normalized.
https://stereokit.net/Pages/StereoKit/Vec2/Angle.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.angle(), 45.0);
let vec2 = Vec2::new(0.0, 1.0);
assert_eq!(vec2.angle(), 90.0);
let vec2 = Vec2::new(-1.0, 1.0);
assert_eq!(vec2.angle(), 135.0);
let vec2 = Vec2::new(-1.0, 0.0);
assert_eq!(vec2.angle(), 180.0);
let vec2 = Vec2::new(-1.0, -1.0);
assert_eq!(vec2.angle(), 225.0);
Sourcepub fn in_radius(&self, point: Self, radius: f32) -> bool
pub fn in_radius(&self, point: Self, radius: f32) -> bool
Checks if a point is within a certain radius of this one. This is an easily readable shorthand of the squared distance check. https://stereokit.net/Pages/StereoKit/Vec2/InRadius.html
point
- The point to check against.radius
- The distance to check within.
Returns true if the points are within radius of each other, false not.
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
let vec2_in = Vec2::new(1.1, 1.1);
let vec2_out = Vec2::new(2.0, 2.0);
assert!(vec2.in_radius(vec2_in, 0.2));
assert!(!vec2.in_radius(vec2_out, 0.2));
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Turns this vector into a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero. Vec2::get_normalized is faster. https://stereokit.net/Pages/StereoKit/Vec2/Normalize.html
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2 = Vec2::new(1.0, 1.0);
assert!((vec2.length() - 1.4142135).abs() < f32::EPSILON);
vec2.normalize();
assert!((vec2.length() - 1.0).abs() < f32::EPSILON);
Sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
This is the length of the vector! Or the distance from the origin to this point. Uses f32::sqrt, so it’s not dirt cheap or anything. https://stereokit.net/Pages/StereoKit/Vec2/Length.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.length(), (2.0f32).sqrt());
Sourcepub fn length_sq(&self) -> f32
pub fn length_sq(&self) -> f32
This is the squared length/magnitude of the vector! It skips the Sqrt call, and just gives you the squared version for speedy calculations that can work with it squared. https://stereokit.net/Pages/StereoKit/Vec2/LengthSq.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.length_sq(), 2.0);
Sourcepub fn magnitude(&self) -> f32
pub fn magnitude(&self) -> f32
Magnitude is the length of the vector! Or the distance from the origin to this point. Uses f32::sqrt, so it’s not dirt cheap or anything. https://stereokit.net/Pages/StereoKit/Vec2/Magnitude.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.length(), vec2.magnitude());
Sourcepub fn magnitude_sq(&self) -> f32
pub fn magnitude_sq(&self) -> f32
This is the squared magnitude of the vector! It skips the Sqrt call, and just gives you the squared version for speedy calculations that can work with it squared. Vec2::length_squared is faster https://stereokit.net/Pages/StereoKit/Vec2/MagnitudeSq.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.length_sq(), vec2.magnitude_sq());
Sourcepub fn get_normalized(&self) -> Self
pub fn get_normalized(&self) -> Self
Creates a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero. https://stereokit.net/Pages/StereoKit/Vec2/Normalized.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert!((vec2.get_normalized().length() - 1.0).abs() < f32::EPSILON);
Sourcepub fn x0y(&self) -> Vec3
pub fn x0y(&self) -> Vec3
Promotes this Vec2 to a Vec3, using 0 for the Y axis. https://stereokit.net/Pages/StereoKit/Vec2/X0Y.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.x0y(), Vec3::new(1.0, 0.0, 1.0));
Sourcepub fn xy0(&self) -> Vec3
pub fn xy0(&self) -> Vec3
Promotes this Vec2 to a Vec3, using 0 for the Z axis. https://stereokit.net/Pages/StereoKit/Vec2/XY0.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.xy0(), Vec3::new(1.0, 1.0, 0.0));
Sourcepub fn yx(&self) -> Self
pub fn yx(&self) -> Self
A transpose swizzle property, returns (y,x) https://stereokit.net/Pages/StereoKit/Vec2/YX.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec2 = Vec2::new(1.1, 1.2);
assert_eq!(vec2.yx(), Vec2::new(1.2, 1.1));
Sourcepub fn angle_between(a: Self, b: Self) -> f32
pub fn angle_between(a: Self, b: Self) -> f32
Calculates a signed angle between two vectors in degrees! Sign will be positive if B is counter-clockwise (left) of A, and negative if B is clockwise (right) of A. Vectors do not need to be normalized. NOTE: Since this will return a positive or negative angle, order of parameters matters! https://stereokit.net/Pages/StereoKit/Vec2/AngleBetween.html
a
- The first, initial vector, A. Does not need to be normalized.b
- The second, final vector, B. Does not need to be normalized.
Returns a signed angle between two vectors in degrees! Sign will be positive if B is counter-clockwise (left) of A, and negative if B is clockwise (right) of A.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::angle_between(vec2_a, vec2_b), 90.0);
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, -1.0);
assert_eq!(Vec2::angle_between(vec2_a, vec2_b), 90.0);
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(-1.0, 0.0);
assert_eq!(Vec2::angle_between(vec2_a, vec2_b), 180.0);
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(1.0, 0.0);
assert_eq!(Vec2::angle_between(vec2_a, vec2_b), 0.0);
Sourcepub fn direction(to: Self, from: Self) -> Self
pub fn direction(to: Self, from: Self) -> Self
Creates a normalized delta vector that points out from an origin point to a target point! https://stereokit.net/Pages/StereoKit/Vec2/Direction.html
to
- The target point.from
- And the origin point!
Returns direction from one point to another.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::direction(vec2_b, vec2_a), Vec2::new(-0.70710677, 0.70710677));
Sourcepub fn distance(a: Self, b: Self) -> f32
pub fn distance(a: Self, b: Self) -> f32
Calculates the distance between two points in space! Make sure they’re in the same coordinate space! Uses a Sqrt, so it’s not blazing fast, prefer DistanceSq when possible. https://stereokit.net/Pages/StereoKit/Vec2/Distance.html
a
- The first point.b
- And the second point.
Returns distance between the two points.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::distance(vec2_a, vec2_b), (2.0f32).sqrt());
Sourcepub fn distance_sq(a: Self, b: Self) -> f32
pub fn distance_sq(a: Self, b: Self) -> f32
Calculates the distance between two points in space, but leaves them squared! Make sure they’re in the same coordinate space! This is a fast function :) https://stereokit.net/Pages/StereoKit/Vec2/DistanceSq.html
a
- The first point.b
- The second point.
Returns distance between the two points, but squared.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::distance_sq(vec2_a, vec2_b), 2.0);
Sourcepub fn dot(a: Self, b: Self) -> f32
pub fn dot(a: Self, b: Self) -> f32
The dot product is an extremely useful operation! One major use is to determine how similar two vectors are. If the vectors are Unit vectors (magnitude/length of 1), then the result will be 1 if the vectors are the same, -1 if they’re opposite, and a gradient in-between with 0 being perpendicular. https://stereokit.net/Pages/StereoKit/Vec2/Dot.html
a
- The first vector.b
- The second vector.
Returns the dot product!
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::dot(vec2_a, vec2_b), 0.0);
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(1.0, 0.0);
assert_eq!(Vec2::dot(vec2_a, vec2_b), 1.0);
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(-1.0, 0.0);
assert_eq!(Vec2::dot(vec2_a, vec2_b), -1.0);
Sourcepub fn from_angles(degree: f32) -> Self
pub fn from_angles(degree: f32) -> Self
Creates a vector pointing in the direction of the angle, with a length of 1. Angles are counter-clockwise, and start from (1,0), so an angle of 90 will be (0,1). https://stereokit.net/Pages/StereoKit/Vec2/FromAngle.html
degrees
- Counter-clockwise angle from(1,0) in degrees.
Returns a unit vector (length of 1), pointing towards degrees.
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::from_angles(0.0);
assert_eq!(vec2, Vec2::new(1.0, 0.0));
let vec2 = Vec2::from_angles(90.0);
assert_eq!(vec2, Vec2::new(0.0, 1.0));
let vec2 = Vec2::from_angles(180.0);
assert_eq!(vec2, Vec2::new(-1.0, 0.0));
let vec2 = Vec2::from_angles(270.0);
assert_eq!(vec2, Vec2::new(0.0, -1.0));
Sourcepub fn lerp(a: Self, b: Self, blend: f32) -> Self
pub fn lerp(a: Self, b: Self, blend: f32) -> Self
Blends (Linear Interpolation) between two vectors, based on a ‘blend’ value, where 0 is a, and 1 is b. Doesn’t clamp percent for you. https://stereokit.net/Pages/StereoKit/Vec2/Lerp.html
a
- The first vector to blend, or ‘0.0’ blend.b
- The second vector to blend, or ‘1.0’ blend.blend
- A value between 0 and 1. Can be outside this range, it’ll just interpolate outside of the a, b range.
Returns an unclamped blend of a and b.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.0);
let vec2_b = Vec2::new(0.0, 1.0);
assert_eq!(Vec2::lerp(vec2_a, vec2_b, 0.5), Vec2::new(0.5, 0.5));
Sourcepub fn max(a: Self, b: Self) -> Self
pub fn max(a: Self, b: Self) -> Self
Returns a vector where each element is the maximum value for each corresponding pair. https://stereokit.net/Pages/StereoKit/Vec2/Max.html
a
- Order isn’t important here.b
- Order isn’t important here.
Returns the maximum value for each corresponding vector pair.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.5);
let vec2_b = Vec2::new(0.9, 1.2);
assert_eq!(Vec2::max(vec2_a, vec2_b), Vec2::new(1.0, 1.2));
Sourcepub fn min(a: Self, b: Self) -> Self
pub fn min(a: Self, b: Self) -> Self
Returns a vector where each element is the minimum value for each corresponding pair. https://stereokit.net/Pages/StereoKit/Vec2/Min.html
a
- Order isn’t important here.b
- Order isn’t important here.
Returns the minimum value for each corresponding vector pair.
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 0.2);
let vec2_b = Vec2::new(0.1, 1.0);
assert_eq!(Vec2::min(vec2_a, vec2_b), Vec2::new(0.1, 0.2));
Trait Implementations§
Source§impl Add for Vec2
Adds matching components together. Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Addition.html
impl Add for Vec2
Adds matching components together. Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Addition.html
Source§impl AddAssign for Vec2
Adds matching components together. Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Addition.html
impl AddAssign for Vec2
Adds matching components together. Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Addition.html
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
vec2_a += vec2_b;
assert_eq!(vec2_a, Vec2::new(3.0, 6.0));
Source§impl Display for Vec2
impl Display for Vec2
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Mostly for debug purposes, this is a decent way to log or inspect the vector in debug mode. Looks like “[x, y]” https://stereokit.net/Pages/StereoKit/Vec2/ToString.html
§Examples
use stereokit_rust::maths::Vec2;
let vec2 = Vec2::new(1.0, 1.0);
assert_eq!(vec2.to_string(), "[x:1, y:1]");
Source§impl Div<Vec2> for f32
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
impl Div<Vec2> for f32
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
Source§impl Div<f32> for Vec2
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
impl Div<f32> for Vec2
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
Source§impl Div for Vec2
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
impl Div for Vec2
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
Source§impl DivAssign<f32> for Vec2
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
impl DivAssign<f32> for Vec2
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2_a = Vec2::new(1.0, 2.0);
vec2_a /= 2.0;
assert_eq!(vec2_a, Vec2::new(0.5, 1.0));
Source§impl DivAssign for Vec2
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
impl DivAssign for Vec2
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec2/op_Division.html
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
vec2_a /= vec2_b;
assert_eq!(vec2_a, Vec2::new(0.5, 0.5));
Source§impl Mul<Vec2> for f32
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
impl Mul<Vec2> for f32
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
Source§impl Mul<f32> for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
impl Mul<f32> for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
Source§impl Mul for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
impl Mul for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
Source§impl MulAssign<f32> for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
impl MulAssign<f32> for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2_a = Vec2::new(1.0, 2.0);
vec2_a *= 2.0;
assert_eq!(vec2_a, Vec2::new(2.0, 4.0));
Source§impl MulAssign for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
impl MulAssign for Vec2
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Multiply.html
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec2;
let vec2_a = Vec2::new(1.0, 2.0);
let mut vec2_b = Vec2::new(2.0, 4.0);
vec2_b *= vec2_a;
assert_eq!(vec2_b, Vec2::new(2.0, 8.0));
Source§impl Neg for Vec2
Vector negation, returns a vector where each component has been negated.
https://stereokit.net/Pages/StereoKit/Vec2/op_UnaryNegation.html
impl Neg for Vec2
Vector negation, returns a vector where each component has been negated. https://stereokit.net/Pages/StereoKit/Vec2/op_UnaryNegation.html
Source§impl PartialEq for Vec2
Warning: Equality with a precision of 0.1 millimeter
impl PartialEq for Vec2
Warning: Equality with a precision of 0.1 millimeter
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Warning: Equality with a precision of 0.1 millimeter
use stereokit_rust::maths::Vec2;
assert_eq!(
Vec2 { x: 0.045863353, y: 0.030000005 } ,
Vec2 { x: 0.045863353, y: 0.030000005 } );
use stereokit_rust::maths::Vec2;
assert_ne!(
Vec2 { x: 10.045863353, y: 0.030000005 } ,
Vec2 { x: 0.045863353, y: 0.030000005 } );
Source§impl Sub for Vec2
Subtracts matching components from eachother. Not commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Subtraction.html
impl Sub for Vec2
Subtracts matching components from eachother. Not commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Subtraction.html
Source§impl SubAssign for Vec2
Subtracts matching components from eachother. Not commutative.
https://stereokit.net/Pages/StereoKit/Vec2/op_Subtraction.html
impl SubAssign for Vec2
Subtracts matching components from eachother. Not commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Subtraction.html
Source§fn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
§Examples
use stereokit_rust::maths::Vec2;
let mut vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
vec2_a -= vec2_b;
assert_eq!(vec2_a, Vec2::new(-1.0, -2.0));
impl Copy for Vec2
Auto Trait Implementations§
impl Freeze for Vec2
impl RefUnwindSafe for Vec2
impl Send for Vec2
impl Sync for Vec2
impl Unpin for Vec2
impl UnwindSafe for Vec2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.