20 lines
537 B
Rust
Raw Normal View History

2024-09-06 13:03:55 -07: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-11 12:06:58 -07:00
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq)]
2024-09-05 13:36:38 -07:00
pub struct Vector<const N:usize,T>{
pub(crate) array:[T;N],
2024-08-23 15:42:48 -07:00
}
2024-09-05 13:36:38 -07:00
crate::impl_vector!();
2024-09-04 13:38:29 -07:00
2024-09-06 13:23:55 -07:00
// Needs const generics for generic case
crate::impl_vector_extend!(2);
crate::impl_vector_extend!(3);
2024-09-04 13:38:29 -07:00
//cross product
2024-09-10 11:32:42 -07:00
#[cfg(feature="named-fields")]
2024-09-06 11:25:46 -07:00
crate::impl_vector_3!();