pub struct Vec4i(/* private fields */);Expand description
A 4-component non-owning view of an integral Euclidean vector.
§Guarantees
This type has the strict requirement that it can only reference a
4-component slice of i32 values. It is guaranteed to never refer to
more or less than 4 entries.
§Relation to Vector4i
Vec4i is a non-owning equivalent of Vector4i. This enables non-vector
types to either Deref or provide conversion-related utilities into
Vec4i types to be able to access and benefit from vector operations.
Implementations§
source§impl Vec4i
impl Vec4i
sourcepub const fn from_array(array: &[i32; 4]) -> &Self
pub const fn from_array(array: &[i32; 4]) -> &Self
Forms a reference to a Vec4i from a 4-component i32 array.
This function is identical to from_slice_unchecked, except it is not
marked unsafe.
§Parameters
array- an array containing 4i32values.
§Examples
Basic use:
let array: [i32; 4] = [1, 42, 314, 9];
let vec = Vec4i::from_array(&array);
assert_eq!(vec.as_ptr(), array.as_ptr());
assert_eq!(vec.x(), array[0]);
assert_eq!(vec.y(), array[1]);
assert_eq!(vec.z(), array[2]);
assert_eq!(vec.w(), array[3]);sourcepub fn from_mut_array(array: &mut [i32; 4]) -> &mut Self
pub fn from_mut_array(array: &mut [i32; 4]) -> &mut Self
Forms a mutable reference to a Vec4i from a 4-component i32 array.
This function is identical to from_mut_slice_unchecked, except it is
not marked unsafe.
§Parameters
array- an array containing 4i32values.
§Examples
Basic use:
let mut array: [i32; 4] = [1, 42, 314, 9];
let vec = Vec4i::from_mut_array(&mut array);
assert_eq!(vec.as_ptr(), array.as_ptr());sourcepub const fn from_slice(slice: &[i32]) -> Result<&Self, VecError>
pub const fn from_slice(slice: &[i32]) -> Result<&Self, VecError>
Forms a reference to a Vec4i from a slice of i32.
This requires that slice.len() == 4, otherwise this returns VecError.
§Parameters
slice- the slice ofi32s.
§Examples
Basic use:
let slice = &[1, 42, 314, 9];
let vec = Vec4i::from_slice(slice).unwrap();
assert_eq!(vec.as_ptr(), slice.as_ptr());
assert_eq!(vec.x(), slice[0]);
assert_eq!(vec.y(), slice[1]);
assert_eq!(vec.z(), slice[2]);
assert_eq!(vec.w(), slice[3]);Invalid size:
let slice = &[1];
let vec = Vec4i::from_slice(slice);
assert!(vec.is_err());sourcepub fn from_mut_slice(slice: &mut [i32]) -> Result<&mut Self, VecError>
pub fn from_mut_slice(slice: &mut [i32]) -> Result<&mut Self, VecError>
Forms a mutable reference to a Vec4i from a mutable slice of i32.
This requires that slice.len() == 4, otherwise this returns VecError.
§Parameters
slice- the mutable slice ofi32s.
§Examples
Basic use:
let slice = &mut [1, 42, 314, 9];
let vec = Vec4i::from_mut_slice(slice).unwrap();
assert_eq!(vec.as_ptr(), slice.as_ptr());Invalid size:
let slice = &mut [1];
let vec = Vec4i::from_mut_slice(slice);
assert!(vec.is_err());sourcepub const unsafe fn from_slice_unchecked(slice: &[i32]) -> &Self
pub const unsafe fn from_slice_unchecked(slice: &[i32]) -> &Self
sourcepub unsafe fn from_mut_slice_unchecked(slice: &mut [i32]) -> &mut Self
pub unsafe fn from_mut_slice_unchecked(slice: &mut [i32]) -> &mut Self
sourcepub const unsafe fn from_ptr_unchecked<'a>(ptr: *const i32) -> &'a Vec4i
pub const unsafe fn from_ptr_unchecked<'a>(ptr: *const i32) -> &'a Vec4i
sourcepub unsafe fn from_mut_ptr_unchecked<'a>(ptr: *mut i32) -> &'a mut Vec4i
pub unsafe fn from_mut_ptr_unchecked<'a>(ptr: *mut i32) -> &'a mut Vec4i
sourcepub fn as_mut_slice(&mut self) -> &mut [i32]
pub fn as_mut_slice(&mut self) -> &mut [i32]
sourcepub fn as_mut_ptr(&mut self) -> *mut i32
pub fn as_mut_ptr(&mut self) -> *mut i32
Returns a mutable raw pointer to i32 of the vector’s buffer.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut i32>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut i32>
Returns a mutable iterator over the vector.
sourcepub fn x_mut(&mut self) -> &mut i32
pub fn x_mut(&mut self) -> &mut i32
Returns a mutable reference to the X-coordinate of this 3-component vector.
sourcepub fn y_mut(&mut self) -> &mut i32
pub fn y_mut(&mut self) -> &mut i32
Returns a mutable reference to the Y-coordinate of this 3-component vector.
sourcepub fn z_mut(&mut self) -> &mut i32
pub fn z_mut(&mut self) -> &mut i32
Returns a mutable reference to the Z-coordinate of this 3-component vector.
sourcepub fn w_mut(&mut self) -> &mut i32
pub fn w_mut(&mut self) -> &mut i32
Returns a mutable reference to the W-coordinate of this 3-component vector.
sourcepub fn xy_mut(&mut self) -> &mut Vec2i
pub fn xy_mut(&mut self) -> &mut Vec2i
Returns a mutable reference to the xy coordinates of this vector.
sourcepub fn yz_mut(&mut self) -> &mut Vec2i
pub fn yz_mut(&mut self) -> &mut Vec2i
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn zw_mut(&mut self) -> &mut Vec2i
pub fn zw_mut(&mut self) -> &mut Vec2i
Returns a mutable reference to the zw coordinates of this vector.
sourcepub fn xyz_mut(&mut self) -> &mut Vec3i
pub fn xyz_mut(&mut self) -> &mut Vec3i
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn yzw_mut(&mut self) -> &mut Vec3i
pub fn yzw_mut(&mut self) -> &mut Vec3i
Returns a mutable reference to the zw coordinates of this vector.
Trait Implementations§
source§impl AddAssign<&Vec4i> for Vec4i
impl AddAssign<&Vec4i> for Vec4i
source§fn add_assign(&mut self, rhs: &Vec4i)
fn add_assign(&mut self, rhs: &Vec4i)
+= operation. Read moresource§impl AddAssign<&Vec4i> for Vector4i
impl AddAssign<&Vec4i> for Vector4i
source§fn add_assign(&mut self, rhs: &Vec4i)
fn add_assign(&mut self, rhs: &Vec4i)
+= operation. Read moresource§impl BorrowMut<[i32]> for Vec4i
impl BorrowMut<[i32]> for Vec4i
source§fn borrow_mut(&mut self) -> &mut [i32]
fn borrow_mut(&mut self) -> &mut [i32]
source§impl BorrowMut<Vec4i> for Vector4i
impl BorrowMut<Vec4i> for Vector4i
source§fn borrow_mut(&mut self) -> &mut Vec4i
fn borrow_mut(&mut self) -> &mut Vec4i
source§impl DivAssign<i32> for Vec4i
impl DivAssign<i32> for Vec4i
source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/= operation. Read moresource§impl MulAssign<i32> for Vec4i
impl MulAssign<i32> for Vec4i
source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*= operation. Read moresource§impl PartialOrd for Vec4i
impl PartialOrd for Vec4i
source§impl RemAssign<i32> for Vec4i
impl RemAssign<i32> for Vec4i
source§fn rem_assign(&mut self, rhs: i32)
fn rem_assign(&mut self, rhs: i32)
%= operation. Read moresource§impl SubAssign<&Vec4i> for Vec4i
impl SubAssign<&Vec4i> for Vec4i
source§fn sub_assign(&mut self, rhs: &Vec4i)
fn sub_assign(&mut self, rhs: &Vec4i)
-= operation. Read moresource§impl SubAssign<&Vec4i> for Vector4i
impl SubAssign<&Vec4i> for Vector4i
source§fn sub_assign(&mut self, rhs: &Vec4i)
fn sub_assign(&mut self, rhs: &Vec4i)
-= operation. Read more