Skip to content

Commit 3c27126

Browse files
committed
Use derived traits for Au
This code did not use derived traits previously because their methods were not inlined, but this was fixed in rust-lang/rust#10557.
1 parent b2e6470 commit 3c27126

File tree

1 file changed

+1
-61
lines changed

1 file changed

+1
-61
lines changed

src/components/util/geometry.rs

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,15 @@ use std::fmt;
1212
// An Au is an "App Unit" and represents 1/60th of a CSS pixel. It was
1313
// originally proposed in 2002 as a standard unit of measure in Gecko.
1414
// See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info.
15+
#[deriving(Clone, Eq, Ord, Zero)]
1516
pub struct Au(pub i32);
1617

17-
// We don't use #[deriving] here for inlining.
18-
impl Clone for Au {
19-
#[inline]
20-
fn clone(&self) -> Au {
21-
let Au(i) = *self;
22-
Au(i)
23-
}
24-
}
25-
2618
impl fmt::Show for Au {
2719
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2820
let Au(n) = *self;
2921
write!(f.buf, "Au({})", n)
3022
}}
3123

32-
impl Eq for Au {
33-
#[inline]
34-
fn eq(&self, other: &Au) -> bool {
35-
let Au(s) = *self;
36-
let Au(o) = *other;
37-
s == o
38-
}
39-
#[inline]
40-
fn ne(&self, other: &Au) -> bool {
41-
let Au(s) = *self;
42-
let Au(o) = *other;
43-
s != o
44-
}
45-
}
46-
4724
impl Add<Au,Au> for Au {
4825
#[inline]
4926
fn add(&self, other: &Au) -> Au {
@@ -98,48 +75,11 @@ impl Neg<Au> for Au {
9875
}
9976
}
10077

101-
impl Ord for Au {
102-
#[inline]
103-
fn lt(&self, other: &Au) -> bool {
104-
let Au(s) = *self;
105-
let Au(o) = *other;
106-
s < o
107-
}
108-
#[inline]
109-
fn le(&self, other: &Au) -> bool {
110-
let Au(s) = *self;
111-
let Au(o) = *other;
112-
s <= o
113-
}
114-
#[inline]
115-
fn ge(&self, other: &Au) -> bool {
116-
let Au(s) = *self;
117-
let Au(o) = *other;
118-
s >= o
119-
}
120-
#[inline]
121-
fn gt(&self, other: &Au) -> bool {
122-
let Au(s) = *self;
123-
let Au(o) = *other;
124-
s > o
125-
}
126-
}
127-
12878
impl One for Au {
12979
#[inline]
13080
fn one() -> Au { Au(1) }
13181
}
13282

133-
impl Zero for Au {
134-
#[inline]
135-
fn zero() -> Au { Au(0) }
136-
#[inline]
137-
fn is_zero(&self) -> bool {
138-
let Au(s) = *self;
139-
s == 0
140-
}
141-
}
142-
14383
impl Num for Au {}
14484

14585
#[inline]

0 commit comments

Comments
 (0)