diff --git a/fixed_wide_vectors/src/macros/length.rs b/fixed_wide_vectors/src/macros/length.rs new file mode 100644 index 0000000..389d7da --- /dev/null +++ b/fixed_wide_vectors/src/macros/length.rs @@ -0,0 +1,15 @@ +#[doc(hidden)] +#[macro_export(local_inner_macros)] +macro_rules! impl_length_operations { + ( $struct: ident { $($field: ident), + }, $size: expr ) => { + impl> $struct { + type Output=$struct; + #[inline] + fn wide_with_length(self, rhs: Self) -> Self::Output { + let len=self.wide_length(); + let ratio=rhs.ratio(len); + self.wide_mul(ratio) + } + } + } +} diff --git a/fixed_wide_vectors/src/macros/mod.rs b/fixed_wide_vectors/src/macros/mod.rs index 0d9be65..7b6f1f9 100644 --- a/fixed_wide_vectors/src/macros/mod.rs +++ b/fixed_wide_vectors/src/macros/mod.rs @@ -1,5 +1,7 @@ #[cfg(feature="fixed_wide_traits")] pub mod wide; +#[cfg(all(feature="fixed_wide_traits",feature="deferred_division"))] +pub mod length; // Stolen from https://github.com/c1m50c/fixed-vectors (MIT license) #[doc(hidden)]