Skip to content

Commit

Permalink
Replace impl that triggered a lint on Rust 1.80
Browse files Browse the repository at this point in the history
The generic Mul for Scalar impl violated orphan rules, but used to
be accepted by rustc due to a bug. Replace the impl with separate concrete
impls for f32, i32, and u32.

See rust-lang/rust#124559 for more info.
  • Loading branch information
jdahlstrom committed Aug 6, 2024
1 parent eab4784 commit 7727575
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions core/src/math/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,31 @@ where
}
}

/// The scalar * vector operator.
impl<R, Sp> Mul<Vector<R, Sp>> for <Vector<R, Sp> as Linear>::Scalar
impl<R, Sp> Mul<Vector<R, Sp>> for f32
where
Vector<R, Sp>: Linear,
Vector<R, Sp>: Linear<Scalar = f32>,
{
type Output = Vector<R, Sp>;

#[inline]
fn mul(self, rhs: Vector<R, Sp>) -> Self::Output {
rhs * self
}
}
impl<R, Sp> Mul<Vector<R, Sp>> for i32
where
Vector<R, Sp>: Linear<Scalar = i32>,
{
type Output = Vector<R, Sp>;

#[inline]
fn mul(self, rhs: Vector<R, Sp>) -> Self::Output {
rhs * self
}
}
impl<R, Sp> Mul<Vector<R, Sp>> for u32
where
Vector<R, Sp>: Linear<Scalar = u32>,
{
type Output = Vector<R, Sp>;

Expand Down

0 comments on commit 7727575

Please sign in to comment.