1
0
Fork 0

lib(vec): support conversion to slices

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-07-07 21:58:09 +02:00
parent db381143a2
commit 40721c4d56
Signed by: mfocko
SSH key fingerprint: SHA256:5YXD7WbPuK60gxnG6DjAwJiS9+swoWj33/HFu8g8JVo
2 changed files with 8 additions and 0 deletions

View file

@ -31,6 +31,10 @@ impl<T: Copy> Vector2D<T> {
pub fn y(&self) -> T { pub fn y(&self) -> T {
self.y self.y
} }
pub fn as_slice(&self) -> [T; 2] {
[self.x, self.y]
}
} }
macro_rules! generate_indices { macro_rules! generate_indices {

View file

@ -29,6 +29,10 @@ impl<T: Copy> Vector3D<T> {
pub fn z(&self) -> T { pub fn z(&self) -> T {
self.z self.z
} }
pub fn as_slice(&self) -> [T; 3] {
[self.x, self.y, self.z]
}
} }
// [TODO] Implement indexing // [TODO] Implement indexing