Skip to main content

array_from_iter

Function array_from_iter 

Source
fn array_from_iter<T, I, const N: usize>(iter: I) -> [T; N]
where I: Iterator<Item = T>,
Examples found in repository?
crates/competitive/src/math/array_vec.rs (line 54)
53    pub fn map<U>(&self, transform: impl FnMut(&T) -> U) -> ArrayVec<U, N> {
54        ArrayVec(array_from_iter(self.0.iter().map(transform)))
55    }
56
57    pub fn zip_with<U, V>(
58        &self,
59        other: &ArrayVec<U, N>,
60        mut combine: impl FnMut(&T, &U) -> V,
61    ) -> ArrayVec<V, N> {
62        ArrayVec(array_from_iter(
63            self.0
64                .iter()
65                .zip(other.0.iter())
66                .map(|(left, right)| combine(left, right)),
67        ))
68    }