So, at the moment, I'm implementing a matrix. This
fn multiply<const P: usize, T>(&self, rhs: T) -> Matrix<R, P>
where
T: AsRef<Matrix<C, P>>,
is the signature of my multiplication method. Notice, that I used AsRef to be able to accept references as well as owned values. Works as it's supposed to be. The problem occurs, when I try to implement operator overloading.
impl<const R: usize, const C: usize, const P: usize> ops::Mul<Matrix<C, P>> for Matrix<R, C> {
type Output = Matrix<R, P>;
fn mul(self, rhs: Matrix<C, P>) -> Self::Output {
self.multiply(rhs)
}
}
I know, that I just could implement 4 different scenarios, but is it also possible to use AsRef here? I did try multiple approaches, but none of them worked.