Struct Vec2

Source
#[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

Source

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

Source

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

Source

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

Source

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

Source

pub const NEG_X: Self

A normalized Vector that points up the X axis, this is the same as new Vec2(-1,0).

Source

pub const NEG_Y: Self

A normalized Vector that points up the Y axis, this is the same as new Vec2(0,-1).

Source

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

Source

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);
Source

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));
Source

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);
Source

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());
Source

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);
Source

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());
Source

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());
Source

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);
Source

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));
Source

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));
Source

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));
Source

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);
Source

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));
Source

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());
Source

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);
Source

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);
Source

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));
Source

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));
Source

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));
Source

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));
Source

pub fn abs(&self) -> Self

Absolute value of each component, this may be usefull in some case

§Examples
use stereokit_rust::maths::Vec2;

let vec2 = Vec2::new(-1.4, 1.2);
assert_eq!(vec2.abs(), Vec2::new(1.4, 1.2));

Trait Implementations§

Source§

impl Add for Vec2

Adds matching components together. Commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Addition.html

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
assert_eq!(vec2_a + vec2_b, Vec2::new(3.0, 6.0));
Source§

type Output = Vec2

The resulting type after applying the + operator.
Source§

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)

§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 Clone for Vec2

Source§

fn clone(&self) -> Vec2

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 Debug for Vec2

Source§

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

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

impl Default for Vec2

Source§

fn default() -> Vec2

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

impl Display for Vec2

Source§

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

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
assert_eq!(2.0 / vec2_a, Vec2::new(2.0, 1.0));
Source§

type Output = Vec2

The resulting type after applying the / operator.
Source§

impl Div<f32> for Vec2

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
assert_eq!(vec2_a / 2.0, Vec2::new(0.5, 1.0));
Source§

type Output = Vec2

The resulting type after applying the / operator.
Source§

impl Div for Vec2

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
assert_eq!(vec2_a / vec2_b, Vec2::new(0.5, 0.5));
Source§

type Output = Vec2

The resulting type after applying the / operator.
Source§

impl DivAssign<f32> for Vec2

Source§

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

Source§

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 From<[f32; 2]> for Vec2

Source§

fn from(val: [f32; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec2> for Vec2

Source§

fn from(val: Vec2) -> Self

Converts to this type from the input type.
Source§

impl From<Vec2> for Vec2

Source§

fn from(val: Vec2) -> Self

Converts to this type from the input type.
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

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
assert_eq!(2.0 * vec2_a, Vec2::new(2.0, 4.0));
Source§

type Output = Vec2

The resulting type after applying the * operator.
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

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
assert_eq!(vec2_a * 2.0, Vec2::new(2.0, 4.0));
Source§

type Output = Vec2

The resulting type after applying the * operator.
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

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
assert_eq!(vec2_a * vec2_b, Vec2::new(2.0, 8.0));
Source§

type Output = Vec2

The resulting type after applying the * operator.
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

Source§

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

Source§

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

Source§

fn neg(self) -> Self::Output

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
assert_eq!(-vec2_a, Vec2::new(-1.0, -2.0));
Source§

type Output = Vec2

The resulting type after applying the - operator.
Source§

impl PartialEq for Vec2

Warning: Equality with a precision of 0.1 millimeter

Source§

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 } );
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 Sub for Vec2

Subtracts matching components from eachother. Not commutative. https://stereokit.net/Pages/StereoKit/Vec2/op_Subtraction.html

Source§

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

§Examples
use stereokit_rust::maths::Vec2;

let vec2_a = Vec2::new(1.0, 2.0);
let vec2_b = Vec2::new(2.0, 4.0);
assert_eq!(vec2_a - vec2_b, Vec2::new(-1.0, -2.0));
Source§

type Output = Vec2

The resulting type after applying the - operator.
Source§

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)

§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));
Source§

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> 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToSmolStr for T
where T: Display + ?Sized,

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more