diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2014-09-19 13:54:57 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2014-09-19 13:54:57 +0100 |
commit | 415bbaeb2e7a3e724d4edecd82b823d681d6a270 (patch) | |
tree | eac42c97bb8f91e3f7fa4d632d2ce5d2ea1053b6 /components/util/geometry.rs | |
parent | 2652d223f50d53ee5a8a07ff4a3d6a25b510d1f1 (diff) | |
download | servo-415bbaeb2e7a3e724d4edecd82b823d681d6a270.tar.gz servo-415bbaeb2e7a3e724d4edecd82b823d681d6a270.zip |
Fix dimensionality of Au
Previously, we implemented:
Au * Au -> Au
Au / Au -> Au
Au % Au -> Au
... which are inconsistent. It should be:
Au * Au -> SquaredAu
Au / Au -> i32
Au % Au -> i32
or:
Au * i32 -> Au
Au / i32 -> Au
Au % i32 -> Au
I picked the latter.
Also, the multiplicative identity does not make sense
when multiplication take two different types.
Diffstat (limited to 'components/util/geometry.rs')
-rw-r--r-- | components/util/geometry.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/components/util/geometry.rs b/components/util/geometry.rs index c87e98e38b7..50fb1a634f6 100644 --- a/components/util/geometry.rs +++ b/components/util/geometry.rs @@ -9,7 +9,7 @@ use geom::size::Size2D; use serialize::{Encodable, Encoder}; use std::default::Default; -use std::num::{NumCast, One, Zero}; +use std::num::{NumCast, Zero}; use std::fmt; // Units for use with geom::length and geom::scale_factor. @@ -102,30 +102,27 @@ impl Sub<Au,Au> for Au { } -impl Mul<Au,Au> for Au { +impl Mul<i32, Au> for Au { #[inline] - fn mul(&self, other: &Au) -> Au { + fn mul(&self, other: &i32) -> Au { let Au(s) = *self; - let Au(o) = *other; - Au(s * o) + Au(s * *other) } } -impl Div<Au,Au> for Au { +impl Div<i32, Au> for Au { #[inline] - fn div(&self, other: &Au) -> Au { + fn div(&self, other: &i32) -> Au { let Au(s) = *self; - let Au(o) = *other; - Au(s / o) + Au(s / *other) } } -impl Rem<Au,Au> for Au { +impl Rem<i32, Au> for Au { #[inline] - fn rem(&self, other: &Au) -> Au { + fn rem(&self, other: &i32) -> Au { let Au(s) = *self; - let Au(o) = *other; - Au(s % o) + Au(s % *other) } } @@ -137,13 +134,6 @@ impl Neg<Au> for Au { } } -impl One for Au { - #[inline] - fn one() -> Au { Au(1) } -} - -impl Num for Au {} - #[inline] pub fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } } #[inline] |