about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-25 03:07:44 -0700
committerbors <bors@rust-lang.org>2013-07-25 03:07:44 -0700
commit906264b50fa6b69eed567388063233bd279242b1 (patch)
treecfe2808a6e0bbb5aec20ade1ee0af8174f8fc34d /src/libextra
parentb30a16c9aefbc568f67c8121f170b6d478102c5f (diff)
parentf37c7cd30651e6514c6ac03a081940e28a53292c (diff)
downloadrust-906264b50fa6b69eed567388063233bd279242b1.tar.gz
rust-906264b50fa6b69eed567388063233bd279242b1.zip
auto merge of #8015 : msullivan/rust/default-methods, r=nikomatsakis
Lots of changes to vtable resolution, handling of super/self method calls in default methods. Fix a lot of trait inheritance bugs.

r? @nikomatsakis 
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/num/bigint.rs5
-rw-r--r--src/libextra/num/rational.rs19
2 files changed, 24 insertions, 0 deletions
diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs
index d940b6d6667..46a74457274 100644
--- a/src/libextra/num/bigint.rs
+++ b/src/libextra/num/bigint.rs
@@ -732,6 +732,11 @@ impl Ord for Sign {
     }
 }
 
+impl TotalEq for Sign {
+    fn equals(&self, other: &Sign) -> bool {
+        *self == *other
+    }
+}
 impl TotalOrd for Sign {
 
     fn cmp(&self, other: &Sign) -> Ordering {
diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs
index 6733599d1ea..ff14009e556 100644
--- a/src/libextra/num/rational.rs
+++ b/src/libextra/num/rational.rs
@@ -110,6 +110,25 @@ cmp_impl!(impl TotalEq, equals)
 cmp_impl!(impl Ord, lt, gt, le, ge)
 cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering)
 
+impl<T: Clone + Integer + Ord> Orderable for Ratio<T> {
+    #[inline]
+    fn min(&self, other: &Ratio<T>) -> Ratio<T> {
+        if *self < *other { self.clone() } else { other.clone() }
+    }
+
+    #[inline]
+    fn max(&self, other: &Ratio<T>) -> Ratio<T> {
+        if *self > *other { self.clone() } else { other.clone() }
+    }
+
+    #[inline]
+    fn clamp(&self, mn: &Ratio<T>, mx: &Ratio<T>) -> Ratio<T> {
+        if *self > *mx { mx.clone()} else
+        if *self < *mn { mn.clone() } else { self.clone() }
+    }
+}
+
+
 /* Arithmetic */
 // a/b * c/d = (a*c)/(b*d)
 impl<T: Clone + Integer + Ord>