Skip to content

Commit a0f8540

Browse files
committed
Fix some impls such that all supertraits are actually implemented.
1 parent e75ec80 commit a0f8540

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

src/libextra/num/bigint.rs

+5
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,11 @@ impl Ord for Sign {
732732
}
733733
}
734734

735+
impl TotalEq for Sign {
736+
fn equals(&self, other: &Sign) -> bool {
737+
*self == *other
738+
}
739+
}
735740
impl TotalOrd for Sign {
736741

737742
fn cmp(&self, other: &Sign) -> Ordering {

src/libextra/num/rational.rs

+19
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ cmp_impl!(impl TotalEq, equals)
110110
cmp_impl!(impl Ord, lt, gt, le, ge)
111111
cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering)
112112

113+
impl<T: Clone + Integer + Ord> Orderable for Ratio<T> {
114+
#[inline]
115+
fn min(&self, other: &Ratio<T>) -> Ratio<T> {
116+
if *self < *other { self.clone() } else { other.clone() }
117+
}
118+
119+
#[inline]
120+
fn max(&self, other: &Ratio<T>) -> Ratio<T> {
121+
if *self > *other { self.clone() } else { other.clone() }
122+
}
123+
124+
#[inline]
125+
fn clamp(&self, mn: &Ratio<T>, mx: &Ratio<T>) -> Ratio<T> {
126+
if *self > *mx { mx.clone()} else
127+
if *self < *mn { mn.clone() } else { self.clone() }
128+
}
129+
}
130+
131+
113132
/* Arithmetic */
114133
// a/b * c/d = (a*c)/(b*d)
115134
impl<T: Clone + Integer + Ord>

src/libstd/cmp.rs

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ pub trait TotalOrd: TotalEq {
8686
fn cmp(&self, other: &Self) -> Ordering;
8787
}
8888

89+
impl TotalEq for Ordering {
90+
#[inline]
91+
fn equals(&self, other: &Ordering) -> bool {
92+
*self == *other
93+
}
94+
}
8995
impl TotalOrd for Ordering {
9096
#[inline]
9197
fn cmp(&self, other: &Ordering) -> Ordering {

src/libstd/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<A, T: DoubleEndedIterator<A>> Iterator<A> for InvertIterator<A, T> {
8686
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
8787
}
8888

89-
impl<A, T: Iterator<A>> DoubleEndedIterator<A> for InvertIterator<A, T> {
89+
impl<A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for InvertIterator<A, T> {
9090
#[inline]
9191
fn next_back(&mut self) -> Option<A> { self.iter.next() }
9292
}

0 commit comments

Comments
 (0)