Skip to content

Commit 7d54803

Browse files
committed
Remove unnecessary bound from Vec::map()
1 parent f46d697 commit 7d54803

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

core/src/math/vec.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ impl<Sp, const N: usize> Vector<[f32; N], Sp> {
150150
}
151151
}
152152

153+
impl<Sc, Sp, const N: usize> Vector<[Sc; N], Sp> {
154+
/// Returns a vector of the same dimension as `self` by applying `f`
155+
/// component-wise.
156+
#[inline]
157+
#[must_use]
158+
pub fn map<T>(self, f: impl FnMut(Sc) -> T) -> Vector<[T; N], Sp> {
159+
self.0.map(f).into()
160+
}
161+
}
162+
153163
impl<Sc, Sp, const N: usize> Vector<[Sc; N], Sp>
154164
where
155165
Self: Linear<Scalar = Sc>,
@@ -203,14 +213,6 @@ where
203213
{
204214
other.mul(self.scalar_project(other))
205215
}
206-
207-
/// Returns a vector of the same dimension as `self` by applying `f`
208-
/// component-wise.
209-
#[inline]
210-
#[must_use]
211-
pub fn map<T>(self, mut f: impl FnMut(Sc) -> T) -> Vector<[T; N], Sp> {
212-
array::from_fn(|i| f(self[i])).into()
213-
}
214216
}
215217

216218
impl<R, Sc, B> Vector<R, Real<2, B>>

0 commit comments

Comments
 (0)