strafe-client-jed/fixed_wide_vectors/src/macros/vector.rs

37 lines
782 B
Rust
Raw Normal View History

2024-09-05 20:36:38 +00:00
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_vector {
() => {
2024-09-05 20:52:54 +00:00
impl<const N:usize,T> Vector<N,T>{
pub const fn new(array:[T;N])->Self{
Self{array}
}
}
impl<const N:usize,T:Copy> Vector<N,T>{
pub const fn from_value(value:T)->Self{
Self{
array:[value;N]
}
}
}
2024-09-05 20:36:38 +00:00
}
}
2024-08-30 19:05:52 +00:00
2024-09-05 20:36:38 +00:00
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_vector_named_fields {
( $struct:ident, $size: expr ) => {
impl<T> core::ops::Deref for Vector<$size,T>{
type Target=$struct<T>;
fn deref(&self)->&Self::Target{
unsafe{core::mem::transmute(&self.array)}
}
}
impl<T> core::ops::DerefMut for Vector<$size,T>{
fn deref_mut(&mut self)->&mut Self::Target{
unsafe{core::mem::transmute(&mut self.array)}
}
}
}
}