about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-08-29 16:11:06 -0700
committerBrian Anderson <banderson@mozilla.com>2012-08-29 16:23:36 -0700
commitc0c8d3aa8fdd054372f91c997913b33146bdf9bd (patch)
tree92ce54582b167358b3f09a0bc3861c643201c1aa /src/libcore
parentee2ce036ccd53d8c19689d86cf8b3bd5cf37f40f (diff)
core: Demode int/uint mods
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/int-template.rs12
-rw-r--r--src/libcore/io.rs2
-rw-r--r--src/libcore/str.rs2
-rw-r--r--src/libcore/uint-template.rs12
-rw-r--r--src/libcore/vec.rs4
5 files changed, 20 insertions, 12 deletions
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 2f32376e715..ac4aceeaa95 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import T = inst::T;
 import cmp::{Eq, Ord};
 import num::from_int;
@@ -21,8 +25,8 @@ const bytes : uint = (inst::bits / 8);
 const min_value: T = (-1 as T) << (bits - 1);
 const max_value: T = min_value - 1 as T;
 
-pure fn min(&&x: T, &&y: T) -> T { if x < y { x } else { y } }
-pure fn max(&&x: T, &&y: T) -> T { if x > y { x } else { y } }
+pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } }
+pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } }
 
 pure fn add(x: &T, y: &T) -> T { *x + *y }
 pure fn sub(x: &T, y: &T) -> T { *x - *y }
@@ -155,7 +159,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: ~str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
 
 /// Convert to a string in a given base
 fn to_str(n: T, radix: uint) -> ~str {
@@ -235,7 +239,7 @@ fn test_to_str() {
 
 #[test]
 fn test_interfaces() {
-    fn test<U:num::Num>(ten: U) {
+    fn test<U:num::Num>(+ten: U) {
         assert (ten.to_int() == 10);
 
         let two: U = from_int(2);
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index d5521b509d4..1fd9b79ad9d 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -284,7 +284,7 @@ type ByteBuf = {buf: &[const u8], mut pos: uint};
 
 impl ByteBuf: Reader {
     fn read(buf: &[mut u8], len: uint) -> uint {
-        let count = uint::min(len, self.buf.len() - self.pos);
+        let count = uint::min(&len, &(self.buf.len() - self.pos));
 
         vec::u8::memcpy(buf,
                         vec::const_view(self.buf, self.pos, self.buf.len()),
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index b0cbf559fec..32665db7966 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -676,7 +676,7 @@ pure fn eq_slice(a: &str, b: &str) -> bool {
     let a_len = a.len();
     let b_len = b.len();
     if a_len != b_len { return false; }
-    let mut end = uint::min(a_len, b_len);
+    let mut end = uint::min(&a_len, &b_len);
 
     let mut i = 0u;
     while i < end {
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index e36d0744b2c..f95848f2496 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import T = inst::T;
 import cmp::{Eq, Ord};
 
@@ -20,8 +24,8 @@ const bytes : uint = (inst::bits / 8);
 const min_value: T = 0 as T;
 const max_value: T = 0 as T - 1 as T;
 
-pure fn min(&&x: T, &&y: T) -> T { if x < y { x } else { y } }
-pure fn max(&&x: T, &&y: T) -> T { if x > y { x } else { y } }
+pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } }
+pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } }
 
 pure fn add(x: &T, y: &T) -> T { *x + *y }
 pure fn sub(x: &T, y: &T) -> T { *x - *y }
@@ -138,10 +142,10 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: ~str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
 
 /// Parse a string as an unsigned integer.
-fn from_str_radix(buf: ~str, radix: u64) -> Option<u64> {
+fn from_str_radix(buf: &str, radix: u64) -> Option<u64> {
     if str::len(buf) == 0u { return None; }
     let mut i = str::len(buf) - 1u;
     let mut power = 1u64, n = 0u64;
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 33199576c11..ee82971c70e 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -1430,7 +1430,7 @@ impl<T: Eq> @[T]: Eq {
 
 pure fn lt<T: Ord>(a: &[T], b: &[T]) -> bool {
     let (a_len, b_len) = (a.len(), b.len());
-    let mut end = uint::min(a_len, b_len);
+    let mut end = uint::min(&a_len, &b_len);
 
     let mut i = 0;
     while i < end {
@@ -1821,7 +1821,7 @@ mod u8 {
     pure fn cmp(a: &~[u8], b: &~[u8]) -> int {
         let a_len = len(*a);
         let b_len = len(*b);
-        let n = uint::min(a_len, b_len) as libc::size_t;
+        let n = uint::min(&a_len, &b_len) as libc::size_t;
         let r = unsafe {
             libc::memcmp(unsafe::to_ptr(*a) as *libc::c_void,
                          unsafe::to_ptr(*b) as *libc::c_void, n) as int