#[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_wide_operations { ( $struct: ident { $($field: ident), + }, $size: expr ) => { impl> fixed_wide::wide::WideMul for $struct { type Output=$struct; #[inline] fn wide_mul(self, rhs: Self) -> Self::Output { $struct{ $( $field: self.$field.wide_mul(rhs.$field) ), + } } } impl,T:Copy+fixed_wide::wide::WideMul> $struct { #[inline] pub fn wide_dot(self, other: Self) -> U { $crate::sum_repeating!( $( + (self.$field.wide_mul(other.$field)) ) + ) } pub fn wide_length_squared(&self) -> U { let squared = $struct { $( $field: self.$field.wide_mul(self.$field) ), + }; $crate::sum_repeating!( $( + squared.$field ) + ) } } }; } // HACK: Allows us to sum repeating tokens in macros. // See: https://stackoverflow.com/a/60187870/17452730 #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! sum_repeating { ( + $($item: tt) * ) => { $($item) * }; }