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