Skip to main content

Vec2

Struct Vec2 

Source
pub struct Vec2<T> {
    pub x: T,
    pub y: T,
}
Expand description

Represents a 2D vector with generic numeric components.

Vec2 is a generic structure that represents a 2-dimensional vector with components x and y. It provides a variety of methods for vector operations, including vector arithmetic, normalization, dot product, distance calculation, and linear interpolation.

§Type Parameters

  • T: The numeric type of the vector components. This type must implement certain traits such as Zero, One, NumAssign, Copy, and others depending on the method.

Fields§

§x: T§y: T

Implementations§

Source§

impl<T> Vec2<T>
where T: NumAssign + Copy,

Source

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

Creates a new vector with the given x and y components.

§Parameters
  • x: The x-coordinate of the vector.
  • y: The y-coordinate of the vector.
§Returns

A Vec2 instance with the specified x and y components.

§Example
let vec = Vec2::new(3.0, 4.0);
assert_eq!(vec.x, 3.0);
assert_eq!(vec.y, 4.0);
Source

pub fn zero() -> Self

Returns a vector with both components set to zero.

This is commonly used to initialize or reset a vector to a zero state.

§Returns

A Vec2 instance where both components are zero.

§Example
let vec = Vec2::zero();
assert_eq!(vec.x, 0.0);
assert_eq!(vec.y, 0.0);
Source

pub fn one() -> Self

Returns a vector with both components set to one.

This is useful for initializing or scaling vectors to a unit state.

§Returns

A Vec2 instance where both components are one.

§Example
let vec = Vec2::one();
assert_eq!(vec.x, 1.0);
assert_eq!(vec.y, 1.0);
Source

pub fn set(v: T) -> Self

Creates a vector with both components set to the given value v.

§Parameters
  • v: The value to be assigned to both the x and y components of the vector.
§Returns

A Vec2 instance where both components are initialized to v.

§Example
let vec = Vec2::set(5.0);
assert_eq!(vec.x, 5.0);
assert_eq!(vec.y, 5.0);
Source

pub fn from_vec3(v: &Vec3<T>) -> Self

Creates a Vec2 from a Vec3 by using the x and y components of the Vec3.

This is useful when you want to convert a 3-dimensional vector to a 2-dimensional vector, discarding the z component.

§Parameters
  • v: A reference to a Vec3 instance from which the x and y components will be used.
§Returns

A Vec2 instance with the x and y components taken from the Vec3 instance.

§Example
let vec3 = Vec3::new(1.0, 2.0, 3.0);
let vec2 = Vec2::from_vec3(&vec3);
assert_eq!(vec2.x, 1.0);
assert_eq!(vec2.y, 2.0);
Source

pub fn from_vec4(v: &Vec4<T>) -> Self

Creates a Vec2 from a Vec4 by using the x and y components of the Vec4.

This is useful when you want to convert a 4-dimensional vector to a 2-dimensional vector, discarding the z and w components.

§Parameters
  • v: A reference to a Vec4 instance from which the x and y components will be used.
§Returns

A Vec2 instance with the x and y components taken from the Vec4 instance.

§Example
let vec4 = Vec4::new(1.0, 2.0, 3.0, 4.0);
let vec2 = Vec2::from_vec4(&vec4);
assert_eq!(vec2.x, 1.0);
assert_eq!(vec2.y, 2.0);
Source

pub fn dot(&self, other: &Self) -> T

Computes the dot product of the vector with another vector.

The dot product is calculated as the sum of the products of the corresponding components of the two vectors. It is a measure of how much one vector extends in the direction of another. The result is a scalar value.

§Arguments
  • other: The other vector with which to compute the dot product.
§Returns

The dot product of the two vectors as a value of type T.

§Constraints
  • T must implement the Mul and Add traits to support multiplication and addition operations.
§Example
let vec1 = Vec2::new(1.0, 2.0);
let vec2 = Vec2::new(3.0, 4.0);
assert_eq!(vec1.dot(&vec2), 11.0);
Source

pub fn length_squared(&self) -> T

Computes the squared length (or magnitude) of the vector.

The squared length is calculated as the sum of the squares of the components of the vector. This is often used in computations where you need the length of the vector but want to avoid the overhead of computing the square root.

§Returns

The squared length of the vector as a value of type T. This is the result of the expression x * x + y * y.

§Constraints
  • T must implement the Mul and Add traits to support multiplication and addition operations.
§Example
let vec = Vec2::new(3.0, 4.0);
assert_eq!(vec.length_squared(), 25.0);
Source

pub fn distance_squared(&self, other: &Self) -> T

Computes the squared distance between this vector and another vector.

This method calculates the squared distance between the two vectors without computing the square root, which can be more efficient, especially when comparing distances or performing multiple distance calculations.

§Arguments
  • other: The other vector to which the squared distance is calculated.
§Returns

The squared distance between the two vectors as a value of type T.

§Constraints
  • T must implement the Sub and Mul traits to support subtraction and multiplication operations.
§Example
let vec1 = Vec2::new(1.0, 2.0);
let vec2 = Vec2::new(4.0, 6.0);
assert_eq!(vec1.distance_squared(&vec2), 25.0);
Source

pub fn transform_mat2(&self, transform: &Mat2<T>) -> Self

Transforms a 2D vector using a 2x2 matrix.

This method applies a 2D affine transformation to a Vec2<T> using a Mat2<T> matrix. The matrix multiplication is performed as follows:

[ x' ] = [ m00  m01 ] [ x ] = [ m00 * x + m01 * y ]
[ y' ]   [ m10  m11 ] [ y ]   [ m10 * x + m11 * y ]

where Vec2<T> is represented as [x, y] and Mat2<T> is represented as:

[ m00  m01 ]
[ m10  m11 ]

Parameters:

  • transform: A reference to a Mat2<T> matrix representing the 2D transformation to be applied.

Returns:

  • A new Vec2<T> that is the result of transforming the original vector by the matrix.

Example:

let vec = Vec2::new(1.0, 2.0);
let mat = Mat2::new(&Vec2::new(1.0, 0.0), &Vec2::new(0.0, 1.0));
let transformed_vec = vec.transform_mat2(&mat);
assert_eq!(transformed_vec, Vec2::new(1.0, 2.0));

This example shows a simple case where the matrix is the identity matrix, and hence the vector remains unchanged.

Source

pub fn transform_mat3(&self, transform: &Mat3<T>) -> Self

Transforms a 2D vector using a 3x3 matrix.

This method applies a 2D affine transformation to a Vec2<T> using a Mat3<T> matrix. The matrix multiplication is performed as follows:

[ x' ] = [ m00  m01  m02 ] [ x ] = [ m00 * x + m01 * y + m02 ]
[ y' ]   [ m10  m11  m12 ] [ y ]   [ m10 * x + m11 * y + m12 ]
[ w' ]   [ 0    0    1  ] [ 1 ]   [ 1 ] // Homogeneous coordinate

where Vec2<T> is represented as [x, y] and Mat3<T> is represented as:

[ m00  m01  m02 ]
[ m10  m11  m12 ]
[ 0    0    1  ]

Parameters:

  • transform: A reference to a Mat3<T> matrix representing the 2D affine transformation to be applied.

Returns:

  • A new Vec2<T> that is the result of transforming the original vector by the matrix.

Example:

let vec = Vec2::new(1.0, 2.0);
let mat = Mat3::new(
    Vec3::new(1.0, 0.0, 3.0), // Translation x
    Vec3::new(0.0, 1.0, 4.0), // Translation y
    Vec3::new(0.0, 0.0, 1.0)  // Homogeneous coordinate
);
let transformed_vec = vec.transform_mat3(&mat);
assert_eq!(transformed_vec, Vec2::new(4.0, 6.0));

In this example, the Mat3 matrix represents a translation, moving the vector (1.0, 2.0) to (4.0, 6.0).

Source§

impl<T> Vec2<T>
where T: NumAssign + Copy + PartialOrd,

Source

pub fn min(&self, other: &Self) -> Self

Returns a new Vec2 containing the component-wise minimum of self and other.

For each component x and y, the method compares the corresponding components of self and other and returns the smaller of the two.

§Parameters
  • other: A reference to another Vec2 instance to compare with self.
§Returns

A new Vec2 where each component is the minimum value between self and other.

§Examples
let vec1 = Vec2::new(3, 7);
let vec2 = Vec2::new(4, 5);
let min_vec = vec1.min(&vec2);
assert_eq!(min_vec, Vec2::new(3, 5));
Source

pub fn max(&self, other: &Self) -> Self

Returns a new Vec2 containing the component-wise maximum of self and other.

For each component x and y, the method compares the corresponding components of self and other and returns the larger of the two.

§Parameters
  • other: A reference to another Vec2 instance to compare with self.
§Returns

A new Vec2 where each component is the maximum value between self and other.

§Examples
let vec1 = Vec2::new(3, 7);
let vec2 = Vec2::new(4, 5);
let max_vec = vec1.max(&vec2);
assert_eq!(max_vec, Vec2::new(4, 7));
Source

pub fn clamp(&self, min: &Self, max: &Self) -> Self

Clamps the components of self to lie within the inclusive range defined by min and max.

For each component x and y, the method compares the corresponding component of self to the provided min and max values and ensures it lies within this range. If a component of self is less than the corresponding component of min, it is set to the min value. If it is greater than the corresponding component of max, it is set to the max value.

§Parameters
  • min: A reference to a Vec2 representing the minimum allowed values for each component.
  • max: A reference to a Vec2 representing the maximum allowed values for each component.
§Returns

A new Vec2 where each component is clamped to the range [min, max].

§Panics

This method will panic if any component of min is greater than the corresponding component of max, as it is not possible to clamp a value within an invalid range.

§Examples
let vec = Vec2::new(5, 10);
let min_vec = Vec2::new(3, 7);
let max_vec = Vec2::new(6, 8);
let clamped_vec = vec.clamp(&min_vec, &max_vec);
assert_eq!(clamped_vec, Vec2::new(5, 8));
Source§

impl<T> Vec2<T>
where T: NumAssign + Float,

Source

pub fn length(&self) -> T

Returns the length (magnitude) of the vector.

The length of the vector is calculated as the Euclidean norm, which is the square root of the sum of the squares of its components.

§Returns

The length (magnitude) of the vector as a value of type T.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let vec = Vec2::new(3.0, 4.0);
assert_eq!(vec.length(), 5.0);
Source

pub fn normalize(&self) -> Option<Self>

Returns a normalized (unit length) version of the vector.

The normalized vector is a unit vector that points in the same direction as the original vector. Normalization is achieved by dividing each component of the vector by its length. If the vector has zero length (is a zero vector), None is returned to indicate that normalization is not possible.

§Returns
  • Some(Self): A new vector with unit length pointing in the same direction as the original vector, if normalization is possible.
  • None: If the vector has zero length, indicating that it cannot be normalized.
§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let vec = Vec2::new(3.0, 4.0);
let normalized = vec.normalize().unwrap();
assert_eq!(normalized.length(), 1.0);
Source

pub fn distance(&self, other: &Self) -> T

Computes the distance between this vector and another vector.

The distance is calculated as the Euclidean distance between the two vectors, which is the length of the vector representing the difference between them.

§Arguments
  • other: The other vector to which the distance is calculated.
§Returns

The distance between the two vectors as a value of type T.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let vec1 = Vec2::new(1.0, 2.0);
let vec2 = Vec2::new(4.0, 6.0);
assert_eq!(vec1.distance(&vec2), 5.0);
Source

pub fn direction(&self, other: &Self) -> Option<Self>

Computes the direction from this vector to another vector.

This method calculates a normalized vector that points from self to other. If self and other are the same vector, resulting in a zero-length vector, None is returned.

§Arguments
  • other: The target vector to which the direction is calculated.
§Returns

An Option<Self> where:

  • Some(Self) contains the normalized direction vector pointing from self to other if the vectors are not identical.
  • None if self and other are identical (i.e., the direction vector has zero length).
§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let vec1 = Vec2::new(1.0, 2.0);
let vec2 = Vec2::new(4.0, 6.0);
if let Some(direction) = vec1.direction(&vec2) {
    assert_eq!(direction, Vec2::new(0.6, 0.8));
} else {
    panic!("The vectors are identical, so no direction can be computed.");
}
Source

pub fn angle(&self, other: &Self) -> T

Computes the angle (in radians) between this vector and another vector.

This method calculates the angle between self and other vectors using the arctangent of the cross product and dot product of the vectors. The result is in radians, and the angle is measured counterclockwise.

§Arguments
  • other: The other vector to which the angle is computed.
§Returns

The angle between the vectors as a value of type T.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let vec1 = Vec2::new(1.0, 0.0);
let vec2 = Vec2::new(0.0, 1.0);
assert_eq!(vec1.angle(&vec2), std::f32::consts::PI / 2.0);
Source

pub fn line_angle(&self, end: &Self) -> T

Computes the angle (in radians) of the line defined by two vectors.

This method calculates the angle of the line segment defined by self and end relative to the positive x-axis. The vectors should be normalized for accurate results. The angle is measured from the positive x-axis to the line, and the result is in radians. The direction is clockwise from the positive x-axis.

§Arguments
  • end: The end point of the line segment from self to end.
§Returns

The angle of the line segment as a value of type T.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let start = Vec2::new(1.0, 1.0);
let end = Vec2::new(4.0, 3.0);
assert_eq!(start.line_angle(&end), (-0.6435011).abs()); // Example result
Source

pub fn lerp(&self, other: &Self, t: T) -> Self

Linearly interpolates between this vector and another vector.

This method performs linear interpolation between self and other based on the parameter t. When t is 0.0, the result is self. When t is 1.0, the result is other. For values of t between 0.0 and 1.0, the result is a point between self and other on the line segment connecting them.

§Arguments
  • other: The vector to interpolate towards.
  • t: The interpolation factor, where t ranges from 0.0 to 1.0.
§Returns

A new vector representing the point that is linearly interpolated between self and other.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let start = Vec2::new(0.0, 0.0);
let end = Vec2::new(10.0, 10.0);
let result = start.lerp(&end, 0.5);
assert_eq!(result, Vec2::new(5.0, 5.0));
Source

pub fn reflect(&self, normal: &Self) -> Self

Computes the reflection of the vector around a given normal vector.

The reflection is calculated using the formula: reflected = self - 2 * (self · normal) * normal where self · normal is the dot product between self and normal.

§Parameters
  • normal: The normal vector around which to reflect. This vector should be normalized.
§Returns

A new vector representing the reflection of self around normal.

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Example
let incident = Vec2::new(1.0, -1.0);
let normal = Vec2::new(0.0, 1.0).normalize().unwrap(); // Normalized normal vector
let reflected = incident.reflect(&normal);
assert_eq!(reflected, Vec2::new(1.0, 1.0)); // Reflection of (1.0, -1.0) around (0.0, 1.0) is (1.0, 1.0)
Source

pub fn refract(&self, normal: &Self, r: T) -> Option<Self>

Computes the direction of a refracted ray.

This function calculates the direction of a refracted ray given the direction of the incoming ray, the normal vector of the surface, and the ratio of the refractive indices of the two media.

§Parameters
  • normal: The normalized normal vector of the interface between two optical media.
  • r: The ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface.
§Returns

An Option<Self>. Returns Some(Self) with the direction of the refracted ray if refraction is possible, or None if refraction is not possible (e.g., due to total internal reflection).

§Constraints
  • T must implement the Float trait, which provides methods for floating-point arithmetic.
§Notes
  • The incoming ray and the normal vector should be normalized.
  • The result will be None if total internal reflection occurs (i.e., d < 0).
Source

pub fn rotate(&self, angle: T) -> Self

Rotates the vector by a given angle (in radians) around the origin.

This method applies a 2D rotation to the vector, rotating it by the specified angle in a counterclockwise direction around the origin (0, 0).

§Arguments
  • angle - The angle of rotation in radians. A positive angle rotates the vector counterclockwise, while a negative angle rotates it clockwise.
§Returns

A new vector that represents the original vector rotated by the specified angle.

§Examples
let v = Vec2::new(1.0, 0.0);
let rotated_v = v.rotate(std::f32::consts::PI / 2.0);
assert_eq!(rotated_v, Vec2::new(0.0, 1.0));
Source

pub fn move_towards(&self, target: &Self, max_distance: T) -> Self

Moves the vector towards a target vector by a specified maximum distance.

This method calculates the direction from the vector to a target vector and moves the vector along that direction by a specified maximum distance. If the target vector is closer than the specified distance, the vector will be moved directly to the target position.

§Arguments
  • target - The target vector to move towards.
  • max_distance - The maximum distance to move. If this distance is greater than the distance to the target, the vector will move directly to the target.
§Returns

A new vector that represents the original vector moved towards the target by the specified distance.

§Examples
let start = Vec2::new(1.0, 1.0);
let target = Vec2::new(4.0, 5.0);
let result = start.move_towards(&target, 2.0);
// result will be a vector closer to the target by 2.0 units.
Source

pub fn recip(&self) -> Self

Computes the reciprocal (1/x) of each component of the vector.

This method returns a new vector where each component is the reciprocal of the corresponding component of the original vector. This is equivalent to element-wise division of 1 by the vector components.

§Returns

A new vector where each component is the reciprocal of the corresponding component of the original vector.

§Panics

This method will panic if any component of the vector is zero, as the reciprocal of zero is undefined and would result in a division by zero error.

§Examples
let v = Vec2::new(2.0, 4.0);
let recip_v = v.recip();
assert_eq!(recip_v, Vec2::new(0.5, 0.25));

Trait Implementations§

Source§

impl<T> Add for Vec2<T>
where T: NumAssign + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl<T> Add<T> for Vec2<T>
where T: NumAssign + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the + operator.
Source§

fn add(self, scalar: T) -> Self

Performs the + operation. Read more
Source§

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

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

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

Source§

fn add_assign(&mut self, scalar: T)

Performs the += operation. Read more
Source§

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

Source§

fn clone(&self) -> Vec2<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for Vec2<T>

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: Default> Default for Vec2<T>

Source§

fn default() -> Vec2<T>

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

impl<T> Display for Vec2<T>
where T: Display,

Source§

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

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

impl<T> Div for Vec2<T>
where T: NumAssign + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl<T> Div<T> for Vec2<T>
where T: NumAssign + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> Self

Performs the / operation. Read more
Source§

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

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

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

Source§

fn div_assign(&mut self, scalar: T)

Performs the /= operation. Read more
Source§

impl<T> From<(T, T)> for Vec2<T>
where T: NumAssign + Copy,

Source§

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

Converts to this type from the input type.
Source§

impl<T> Index<usize> for Vec2<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for Vec2<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Into<(T, T)> for Vec2<T>
where T: NumAssign + Copy,

Source§

fn into(self) -> (T, T)

Converts this type into the (usually inferred) input type.
Source§

impl<'a, T> IntoIterator for &'a Vec2<T>
where T: NumAssign + Copy,

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut Vec2<T>
where T: NumAssign + Copy,

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

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

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

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

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: T) -> Self

Performs the * operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, scalar: T)

Performs the *= operation. Read more
Source§

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

Source§

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: PartialEq> PartialEq for Vec2<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T> StructuralPartialEq for Vec2<T>

Source§

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

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

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

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn sub(self, scalar: T) -> Self

Performs the - operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, scalar: T)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Vec2<T>
where T: Freeze,

§

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> UnsafeUnpin for Vec2<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Vec2<T>
where T: UnwindSafe,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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