vectors: extend
This commit is contained in:
parent
20285f0f98
commit
d713b96ad3
@ -248,6 +248,22 @@ macro_rules! impl_vector {
|
||||
}
|
||||
|
||||
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! impl_vector_extend {
|
||||
( ($struct: ident { $($field: ident), + }), ($struct_extended: ident, $field_extended: ident) ) => {
|
||||
impl<T> $struct<T> {
|
||||
#[inline(always)]
|
||||
pub fn extend(self,value:T) -> $struct_extended<T> {
|
||||
$struct_extended {
|
||||
$( $field:self.$field, ) +
|
||||
$field_extended:value
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! impl_vector_operator {
|
||||
|
@ -67,6 +67,9 @@ crate::impl_vector!(Vector2 { x, y }, (T, T), 2);
|
||||
crate::impl_vector!(Vector3 { x, y, z }, (T, T, T), 3);
|
||||
crate::impl_vector!(Vector4 { x, y, z, w }, (T, T, T, T), 4);
|
||||
|
||||
crate::impl_vector_extend!((Vector2 { x, y }), (Vector3, z));
|
||||
crate::impl_vector_extend!((Vector3 { x, y, z }), (Vector4, w));
|
||||
|
||||
crate::impl_matrix!((Vector2 { x, y }, ((T, T), (T, T)), 2), (Vector2, 2), (Vector2 { x, y }) );
|
||||
crate::impl_matrix!((Vector2 { x, y }, ((T, T, T), (T, T, T)), 2), (Vector3, 3), (Vector3 { x, y, z }) );
|
||||
crate::impl_matrix!((Vector2 { x, y }, ((T, T, T, T), (T, T, T, T)), 2), (Vector4, 4), (Vector4 { x, y, z, w }) );
|
||||
|
Loading…
Reference in New Issue
Block a user