lib(vec): support conversion to slices
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
db381143a2
commit
40721c4d56
2 changed files with 8 additions and 0 deletions
|
@ -31,6 +31,10 @@ impl<T: Copy> Vector2D<T> {
|
|||
pub fn y(&self) -> T {
|
||||
self.y
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> [T; 2] {
|
||||
[self.x, self.y]
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! generate_indices {
|
||||
|
|
|
@ -29,6 +29,10 @@ impl<T: Copy> Vector3D<T> {
|
|||
pub fn z(&self) -> T {
|
||||
self.z
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> [T; 3] {
|
||||
[self.x, self.y, self.z]
|
||||
}
|
||||
}
|
||||
|
||||
// [TODO] Implement indexing
|
||||
|
|
Loading…
Reference in a new issue