Skip to content

Commit

Permalink
Remove unnecessary bound from Vec::map()
Browse files Browse the repository at this point in the history
  • Loading branch information
jdahlstrom committed Oct 1, 2024
1 parent b784177 commit 0f5fb7c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/src/math/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ impl<Sp, const N: usize> Vector<[f32; N], Sp> {
}
}

impl<Sc, Sp, const N: usize> Vector<[Sc; N], Sp> {
/// Returns a vector of the same dimension as `self` by applying `f`
/// component-wise.
#[inline]
#[must_use]
pub fn map<T>(self, f: impl FnMut(Sc) -> T) -> Vector<[T; N], Sp> {
self.0.map(f).into()
}
}

impl<Sc, Sp, const N: usize> Vector<[Sc; N], Sp>
where
Self: Linear<Scalar = Sc>,
Expand Down Expand Up @@ -206,14 +216,6 @@ where
{
other.mul(self.scalar_project(other))
}

/// Returns a vector of the same dimension as `self` by applying `f`
/// component-wise.
#[inline]
#[must_use]
pub fn map<T>(self, mut f: impl FnMut(Sc) -> T) -> Vector<[T; N], Sp> {
array::from_fn(|i| f(self[i])).into()
}
}

impl<R, Sc, B> Vector<R, Real<2, B>>
Expand Down

0 comments on commit 0f5fb7c

Please sign in to comment.