strafe-project/fixed_wide_vectors/src/vector.rs

19 lines
500 B
Rust
Raw Normal View History

2024-09-06 20:03:55 +00:00
/// An array-backed vector type. Named fields are made accessible via the Deref/DerefMut traits which are implmented for 2-4 dimensions.
/// let mut v = Vector::new([1.0,2.0,3.0]);
/// v.x += v.z;
/// println!("v.x={}",v.x);
2024-09-05 22:43:02 +00:00
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
2024-09-05 20:36:38 +00:00
pub struct Vector<const N:usize,T>{
pub(crate) array:[T;N],
2024-08-23 22:42:48 +00:00
}
2024-09-05 20:36:38 +00:00
crate::impl_vector!();
2024-09-04 20:38:29 +00:00
2024-09-06 20:23:55 +00:00
// Needs const generics for generic case
crate::impl_vector_extend!(2);
crate::impl_vector_extend!(3);
2024-09-04 20:38:29 +00:00
//cross product
2024-09-06 18:25:46 +00:00
crate::impl_vector_3!();