From d560242ed4ad761ad16986c92f4299c6adddd2e1 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sun, 19 Apr 2015 15:45:13 +0200 Subject: [PATCH] Allow writing `matrix * scalar` --- src/matrix.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/matrix.rs b/src/matrix.rs index ca6d3ea..4355630 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -510,6 +510,13 @@ impl Mul for Matrix2 { fn mul(self, other: Matrix2) -> Matrix2 { self.mul_m(&other) } } +impl Mul for Matrix2 { + type Output = Matrix2; + + #[inline] + fn mul(self, other: S) -> Matrix2 { self.mul_s(other) } +} + impl Mul for Matrix3 { type Output = Matrix3; @@ -517,6 +524,13 @@ impl Mul for Matrix3 { fn mul(self, other: Matrix3) -> Matrix3 { self.mul_m(&other) } } +impl Mul for Matrix3 { + type Output = Matrix3; + + #[inline] + fn mul(self, other: S) -> Matrix3 { self.mul_s(other) } +} + impl Mul for Matrix4 { type Output = Matrix4; @@ -524,6 +538,13 @@ impl Mul for Matrix4 { fn mul(self, other: Matrix4) -> Matrix4 { self.mul_m(&other) } } +impl Mul for Matrix4 { + type Output = Matrix4; + + #[inline] + fn mul(self, other: S) -> Matrix4 { self.mul_s(other) } +} + impl One for Matrix2 { #[inline] fn one() -> Matrix2 { Matrix2::identity() }