#[repr(C)]
pub struct Vector2<T> {
pub x: T,
pub y: T,
}
Expand description
A vector containing two numeric values. This may represent a size or
position.
The horizontal component of the vector.
The vertical component of the vector.
Instantiates a new Vector2
from the specified horizontal and vertical
components.
A constant representing a vector of zero magnitude. Each component is
set to zero.
Returns the magnitude of the vector, squared.
Returns the magnitude of the vector.
Normalizes the vector so that the magnitude is 1.0
. If the current
magnitude of the vector is 0.0
, then None
is returned to avoid a
division by zero.
Rotates the vector by 90 degrees in the clockwise direction.
Rotates the vector by 90 degrees in the anti-clockwise direction.
Returns a new vector with each element cast to f32
, using the as
operator.
Returns a new vector with each element cast to i32
, using the as
operator.
Attempts to convert each element of this vector to an i32
, returning
an error if this fails.
The resulting type after applying the +
operator.
The resulting type after applying the +
operator.
The resulting type after applying the +
operator.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
The resulting type after applying the /
operator.
The resulting type after applying the /
operator.
The resulting type after applying the *
operator.
The resulting type after applying the *
operator.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Round this value to the nearest integer. In the case of vectors or other
types containing multiple elements, each element will be
individually rounded. Read more
The resulting type after applying the -
operator.
The resulting type after applying the -
operator.
The resulting type after applying the -
operator.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.