Explicit version of `zip_with`
(f: F, xs: &[T], ys: &[T])
| 549 | |
| 550 | /// Explicit version of `zip_with` |
| 551 | pub fn zip_with<F, T>(f: F, xs: &[T], ys: &[T]) -> Vec<T> |
| 552 | where |
| 553 | F: Fn(T, T) -> T, |
| 554 | T: Default + Copy, |
| 555 | { |
| 556 | let l = min(xs.len(), ys.len()); |
| 557 | let mut result = vec![T::default(); l]; |
| 558 | for i in 0..l { |
| 559 | result[i] = f(xs[i], ys[i]); |
| 560 | } |
| 561 | result |
| 562 | } |
| 563 | |
| 564 | /// Explicit version of `zip_with` in parallel |
| 565 | #[cfg(feature = "parallel")] |