diff --git a/fixed_wide_vectors/src/macros/vector.rs b/fixed_wide_vectors/src/macros/vector.rs index e8da06b..3af837a 100644 --- a/fixed_wide_vectors/src/macros/vector.rs +++ b/fixed_wide_vectors/src/macros/vector.rs @@ -250,7 +250,7 @@ macro_rules! impl_vector { #[doc(hidden)] #[macro_export(local_inner_macros)] -macro_rules! impl_vector_extend { +macro_rules! impl_extend { ( $struct: ident { $($field: ident), + }, $struct_extended: ident, $field_extended: ident ) => { impl $struct { #[inline(always)] diff --git a/fixed_wide_vectors/src/matrix.rs b/fixed_wide_vectors/src/matrix.rs index f95a0ee..9a658b8 100644 --- a/fixed_wide_vectors/src/matrix.rs +++ b/fixed_wide_vectors/src/matrix.rs @@ -16,6 +16,9 @@ pub struct Matrix4 { pub w_axis: T, } +crate::impl_extend!(Matrix2 { x_axis, y_axis }, Matrix3, z_axis); +crate::impl_extend!(Matrix3 { x_axis, y_axis, z_axis }, Matrix4, w_axis); + crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T), (T, T)), 2), (Vector2, 2), (Vector2 { x, y }) ); crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T, T), (T, T, T)), 2), (Vector3, 3), (Vector3 { x, y, z }) ); crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T, T, T), (T, T, T, T)), 2), (Vector4, 4), (Vector4 { x, y, z, w }) ); diff --git a/fixed_wide_vectors/src/vector.rs b/fixed_wide_vectors/src/vector.rs index 6f95a15..b9df27c 100644 --- a/fixed_wide_vectors/src/vector.rs +++ b/fixed_wide_vectors/src/vector.rs @@ -67,8 +67,8 @@ 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_extend!(Vector2 { x, y }, Vector3, z); +crate::impl_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 }) );